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
44764797
Commit
44764797
authored
Jun 10, 2020
by
JoyJ
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
code format
parent
b448b34a
Changes
48
Hide whitespace changes
Inline
Side-by-side
Showing
48 changed files
with
3529 additions
and
3457 deletions
+3529
-3457
DataEditorX/CodeEditForm.cs
DataEditorX/CodeEditForm.cs
+27
-27
DataEditorX/Common/CheckUpdate.cs
DataEditorX/Common/CheckUpdate.cs
+26
-26
DataEditorX/Common/ConfHelper.cs
DataEditorX/Common/ConfHelper.cs
+3
-4
DataEditorX/Common/MyBitmap.cs
DataEditorX/Common/MyBitmap.cs
+12
-12
DataEditorX/Common/MyPath.cs
DataEditorX/Common/MyPath.cs
+56
-56
DataEditorX/Common/MySortList.cs
DataEditorX/Common/MySortList.cs
+30
-32
DataEditorX/Common/MyUtils.cs
DataEditorX/Common/MyUtils.cs
+38
-38
DataEditorX/Common/StrUtil.cs
DataEditorX/Common/StrUtil.cs
+37
-37
DataEditorX/Common/User32.cs
DataEditorX/Common/User32.cs
+7
-8
DataEditorX/Common/XMLReader.cs
DataEditorX/Common/XMLReader.cs
+1
-6
DataEditorX/Common/ZipStorer.cs
DataEditorX/Common/ZipStorer.cs
+18
-16
DataEditorX/Config/CodeConfig.cs
DataEditorX/Config/CodeConfig.cs
+3
-4
DataEditorX/Config/DataConfig.cs
DataEditorX/Config/DataConfig.cs
+3
-3
DataEditorX/Config/DataManager.cs
DataEditorX/Config/DataManager.cs
+6
-6
DataEditorX/Config/ImageSet.cs
DataEditorX/Config/ImageSet.cs
+8
-10
DataEditorX/Config/MyConfig.cs
DataEditorX/Config/MyConfig.cs
+38
-37
DataEditorX/Config/YgoPath.cs
DataEditorX/Config/YgoPath.cs
+50
-53
DataEditorX/Controls/DFlowLayoutPanel.cs
DataEditorX/Controls/DFlowLayoutPanel.cs
+1
-4
DataEditorX/Controls/DListBox.cs
DataEditorX/Controls/DListBox.cs
+1
-4
DataEditorX/Controls/DListView.cs
DataEditorX/Controls/DListView.cs
+1
-4
DataEditorX/Controls/FastColoredTextBoxEx.cs
DataEditorX/Controls/FastColoredTextBoxEx.cs
+28
-31
DataEditorX/Controls/History.cs
DataEditorX/Controls/History.cs
+6
-6
DataEditorX/Controls/IEditForm.cs
DataEditorX/Controls/IEditForm.cs
+1
-5
DataEditorX/Controls/MySyntaxHighlighter.cs
DataEditorX/Controls/MySyntaxHighlighter.cs
+22
-28
DataEditorX/Core/Card.cs
DataEditorX/Core/Card.cs
+136
-130
DataEditorX/Core/CardEdit.cs
DataEditorX/Core/CardEdit.cs
+269
-266
DataEditorX/Core/CommandManager.cs
DataEditorX/Core/CommandManager.cs
+75
-75
DataEditorX/Core/DataBase.cs
DataEditorX/Core/DataBase.cs
+415
-404
DataEditorX/Core/Info/CardAttribute.cs
DataEditorX/Core/Info/CardAttribute.cs
+0
-1
DataEditorX/Core/Info/CardLink.cs
DataEditorX/Core/Info/CardLink.cs
+17
-17
DataEditorX/Core/Info/CardRace.cs
DataEditorX/Core/Info/CardRace.cs
+0
-1
DataEditorX/Core/Info/CardRule.cs
DataEditorX/Core/Info/CardRule.cs
+1
-1
DataEditorX/Core/Info/CardType.cs
DataEditorX/Core/Info/CardType.cs
+185
-177
DataEditorX/Core/LuaFunction.cs
DataEditorX/Core/LuaFunction.cs
+272
-263
DataEditorX/Core/Mse/CardPack.cs
DataEditorX/Core/Mse/CardPack.cs
+86
-83
DataEditorX/Core/Mse/MSEConfig.cs
DataEditorX/Core/Mse/MSEConfig.cs
+165
-159
DataEditorX/Core/Mse/MSECons.cs
DataEditorX/Core/Mse/MSECons.cs
+1
-5
DataEditorX/Core/Mse/MseMaker.cs
DataEditorX/Core/Mse/MseMaker.cs
+792
-742
DataEditorX/Core/TCGEditor/CardSet.cs
DataEditorX/Core/TCGEditor/CardSet.cs
+64
-58
DataEditorX/Core/TaskHelper.cs
DataEditorX/Core/TaskHelper.cs
+375
-379
DataEditorX/Core/YGOUtil.cs
DataEditorX/Core/YGOUtil.cs
+34
-35
DataEditorX/DataEditForm.cs
DataEditorX/DataEditForm.cs
+168
-141
DataEditorX/Language/LMsg.cs
DataEditorX/Language/LMsg.cs
+4
-5
DataEditorX/Language/LanguageHelper.cs
DataEditorX/Language/LanguageHelper.cs
+2
-2
DataEditorX/Language/MyMsg.cs
DataEditorX/Language/MyMsg.cs
+15
-20
DataEditorX/MainForm.cs
DataEditorX/MainForm.cs
+19
-21
DataEditorX/Program.cs
DataEditorX/Program.cs
+11
-14
DataEditorX/Properties/AssemblyInfo.cs
DataEditorX/Properties/AssemblyInfo.cs
+0
-1
No files found.
DataEditorX/CodeEditForm.cs
View file @
44764797
...
...
@@ -5,19 +5,19 @@
* 时间: 19:16
*
*/
using
DataEditorX.Config
;
using
DataEditorX.Controls
;
using
DataEditorX.Core
;
using
DataEditorX.Language
;
using
FastColoredTextBoxNS
;
using
System
;
using
System.IO
;
using
System.Drawing
;
using
System.Collections.Generic
;
using
System.Windows.Forms
;
using
System.Drawing
;
using
System.IO
;
using
System.Text
;
using
WeifenLuo.WinFormsUI.Docking
;
using
FastColoredTextBoxNS
;
using
DataEditorX.Language
;
using
System.Text.RegularExpressions
;
using
DataEditorX.Core
;
using
DataEditorX.Config
;
using
DataEditorX.Controls
;
using
System.Windows.Forms
;
using
WeifenLuo.WinFormsUI.Docking
;
namespace
DataEditorX
{
...
...
@@ -91,8 +91,8 @@ void InitForm()
this
.
popupMenu
.
ForeColor
=
this
.
fctb
.
ForeColor
;
this
.
popupMenu
.
Closed
+=
new
ToolStripDropDownClosedEventHandler
(
this
.
popupMenu_Closed
);
this
.
popupMenu
.
SelectedColor
=
Color
.
LightGray
;
popupMenu
.
VisibleChanged
+=
this
.
PopupMenu_VisibleChanged
;
popupMenu
.
Items
.
FocussedItemIndexChanged
+=
this
.
Items_FocussedItemIndexChanged
;
this
.
popupMenu
.
VisibleChanged
+=
this
.
PopupMenu_VisibleChanged
;
this
.
popupMenu
.
Items
.
FocussedItemIndexChanged
+=
this
.
Items_FocussedItemIndexChanged
;
this
.
title
=
this
.
Text
;
}
...
...
@@ -105,38 +105,38 @@ private void ToolTip_Popup(object sender, PopupEventArgs e)
private
void
PopupMenu_VisibleChanged
(
object
sender
,
EventArgs
e
)
{
this
.
AdjustPopupMenuSize
();
if
(!
popupMenu
.
Visible
||
popupMenu
.
Items
.
FocussedItem
==
null
)
if
(!
this
.
popupMenu
.
Visible
||
this
.
popupMenu
.
Items
.
FocussedItem
==
null
)
{
return
;
}
this
.
fctb
.
ShowTooltipWithLabel
(
popupMenu
.
Items
.
FocussedItem
.
ToolTipTitle
,
popupMenu
.
Items
.
FocussedItem
.
ToolTipText
);
this
.
fctb
.
ShowTooltipWithLabel
(
this
.
popupMenu
.
Items
.
FocussedItem
.
ToolTipTitle
,
this
.
popupMenu
.
Items
.
FocussedItem
.
ToolTipText
);
}
private
void
AdjustPopupMenuSize
()
{
if
(!
popupMenu
.
Visible
||
popupMenu
.
Items
.
FocussedItem
==
null
)
if
(!
this
.
popupMenu
.
Visible
||
this
.
popupMenu
.
Items
.
FocussedItem
==
null
)
{
popupMenu
.
Size
=
new
Size
(
300
,
0
);
popupMenu
.
MinimumSize
=
new
Size
(
300
,
0
);
this
.
popupMenu
.
Size
=
new
Size
(
300
,
0
);
this
.
popupMenu
.
MinimumSize
=
new
Size
(
300
,
0
);
}
Size
s
=
TextRenderer
.
MeasureText
(
popupMenu
.
Items
.
FocussedItem
.
ToolTipTitle
,
popupMenu
.
Items
.
Font
,
new
Size
(
0
,
0
),
TextFormatFlags
.
NoPadding
);
s
=
new
Size
(
s
.
Width
+
50
,
popupMenu
.
Size
.
Height
);
if
(
popupMenu
.
Size
.
Width
<
s
.
Width
)
Size
s
=
TextRenderer
.
MeasureText
(
this
.
popupMenu
.
Items
.
FocussedItem
.
ToolTipTitle
,
this
.
popupMenu
.
Items
.
Font
,
new
Size
(
0
,
0
),
TextFormatFlags
.
NoPadding
);
s
=
new
Size
(
s
.
Width
+
50
,
this
.
popupMenu
.
Size
.
Height
);
if
(
this
.
popupMenu
.
Size
.
Width
<
s
.
Width
)
{
popupMenu
.
Size
=
s
;
popupMenu
.
MinimumSize
=
s
;
this
.
popupMenu
.
Size
=
s
;
this
.
popupMenu
.
MinimumSize
=
s
;
}
}
private
void
Items_FocussedItemIndexChanged
(
object
sender
,
EventArgs
e
)
{
if
(
popupMenu
.
Items
.
FocussedItem
==
null
)
if
(
this
.
popupMenu
.
Items
.
FocussedItem
==
null
)
{
return
;
}
this
.
AdjustPopupMenuSize
();
this
.
fctb
.
ShowTooltipWithLabel
(
popupMenu
.
Items
.
FocussedItem
.
ToolTipTitle
,
popupMenu
.
Items
.
FocussedItem
.
ToolTipText
);
this
.
fctb
.
ShowTooltipWithLabel
(
this
.
popupMenu
.
Items
.
FocussedItem
.
ToolTipTitle
,
this
.
popupMenu
.
Items
.
FocussedItem
.
ToolTipText
);
}
void
popupMenu_Closed
(
object
sender
,
ToolStripDropDownClosedEventArgs
e
)
...
...
@@ -258,7 +258,7 @@ public void InitTooltip(CodeConfig codeconfig)
this
.
popupMenu
.
Items
.
SetAutocompleteItems
(
this
.
items
);
}
#
endregion
#
region
悬停的函数说明
//查找函数说明
string
FindTooltip
(
string
word
)
...
...
DataEditorX/Common/CheckUpdate.cs
View file @
44764797
...
...
@@ -64,30 +64,30 @@ public static string GetNewVersion(string VERURL)
public
static
bool
CheckVersion
(
string
ver
,
string
oldver
)
{
bool
hasNew
=
false
;
#
if
DEBUG
System
.
Windows
.
Forms
.
MessageBox
.
Show
(
oldver
+
"=>"
+
ver
);
#
endif
#if DEBUG
System
.
Windows
.
Forms
.
MessageBox
.
Show
(
oldver
+
"=>"
+
ver
);
#endif
string
[]
vers
=
ver
.
Split
(
'.'
);
string
[]
oldvers
=
oldver
.
Split
(
'.'
);
if
(
vers
.
Length
==
oldvers
.
Length
)
{
//从左到右比较数字
for
(
int
i
=
0
;
i
<
oldvers
.
Length
;
i
++)
{
int
.
TryParse
(
vers
[
i
],
out
int
j
);
int
.
TryParse
(
oldvers
[
i
],
out
int
k
);
if
(
j
>
k
)
//新的版本号大于旧的
{
hasNew
=
true
;
break
;
}
else
if
(
j
<
k
)
{
hasNew
=
false
;
break
;
}
}
}
//从左到右比较数字
for
(
int
i
=
0
;
i
<
oldvers
.
Length
;
i
++)
{
int
.
TryParse
(
vers
[
i
],
out
int
j
);
int
.
TryParse
(
oldvers
[
i
],
out
int
k
);
if
(
j
>
k
)
//新的版本号大于旧的
{
hasNew
=
true
;
break
;
}
else
if
(
j
<
k
)
{
hasNew
=
false
;
break
;
}
}
}
return
hasNew
;
}
#
endregion
...
...
@@ -107,12 +107,12 @@ public static string GetHtmlContentByUrl(string url)
(
HttpWebRequest
)
WebRequest
.
Create
(
url
);
httpWebRequest
.
Timeout
=
15000
;
using
(
HttpWebResponse
httpWebResponse
=
(
HttpWebResponse
)
httpWebRequest
.
GetResponse
())
(
HttpWebResponse
)
httpWebRequest
.
GetResponse
())
{
using
(
Stream
stream
=
httpWebResponse
.
GetResponseStream
())
{
using
(
StreamReader
streamReader
=
new
StreamReader
(
stream
,
Encoding
.
UTF8
))
new
StreamReader
(
stream
,
Encoding
.
UTF8
))
{
htmlContent
=
streamReader
.
ReadToEnd
();
streamReader
.
Close
();
...
...
@@ -142,11 +142,11 @@ public static bool DownLoad(string filename)
try
{
if
(
File
.
Exists
(
filename
))
{
File
.
Delete
(
filename
);
}
{
File
.
Delete
(
filename
);
}
HttpWebRequest
Myrq
=
(
HttpWebRequest
)
WebRequest
.
Create
(
URL
);
HttpWebRequest
Myrq
=
(
HttpWebRequest
)
WebRequest
.
Create
(
URL
);
HttpWebResponse
myrp
=
(
HttpWebResponse
)
Myrq
.
GetResponse
();
long
totalBytes
=
myrp
.
ContentLength
;
...
...
DataEditorX/Common/ConfHelper.cs
View file @
44764797
using
System
;
using
System.Collections.Generic
;
using
System.Text
;
using
System.Collections.Generic
;
using
System.Globalization
;
using
System.Text
;
namespace
DataEditorX.Common
{
...
...
@@ -109,7 +108,7 @@ public static int GetIntegerValue(string line, int defalut)
i
=
int
.
Parse
(
GetValue
(
line
));
return
i
;
}
catch
{
}
catch
{
}
return
defalut
;
}
/// <summary>
...
...
DataEditorX/Common/MyBitmap.cs
View file @
44764797
...
...
@@ -2,10 +2,10 @@
* date :2014-02-07
* desc :图像处理,裁剪,缩放,保存
*/
using
System.IO
;
using
System.Drawing
;
using
System.Drawing.Drawing2D
;
using
System.Drawing.Imaging
;
using
System.IO
;
namespace
DataEditorX.Common
{
...
...
@@ -35,7 +35,7 @@ public static Bitmap ReadImage(string file)
/// <returns>处理好的图像</returns>
public
static
Bitmap
Zoom
(
Bitmap
sourceBitmap
,
int
newWidth
,
int
newHeight
)
{
if
(
sourceBitmap
!=
null
)
if
(
sourceBitmap
!=
null
)
{
Bitmap
b
=
new
Bitmap
(
newWidth
,
newHeight
);
Graphics
graphics
=
Graphics
.
FromImage
(
b
);
...
...
@@ -79,17 +79,17 @@ public static Bitmap Cut(Bitmap sourceBitmap, Area area)
/// <returns>处理好的图像</returns>
public
static
Bitmap
Cut
(
Bitmap
sourceBitmap
,
int
StartX
,
int
StartY
,
int
cutWidth
,
int
cutHeight
)
{
if
(
sourceBitmap
!=
null
)
if
(
sourceBitmap
!=
null
)
{
int
w
=
sourceBitmap
.
Width
;
int
h
=
sourceBitmap
.
Height
;
//裁剪的区域宽度调整
if
(
(
StartX
+
cutWidth
)
>
w
)
if
(
(
StartX
+
cutWidth
)
>
w
)
{
cutWidth
=
w
-
StartX
;
}
//裁剪的区域高度调整
if
(
(
StartY
+
cutHeight
)
>
h
)
if
(
(
StartY
+
cutHeight
)
>
h
)
{
cutHeight
=
h
-
StartY
;
}
...
...
@@ -121,12 +121,12 @@ public static Bitmap Cut(Bitmap sourceBitmap, int StartX, int StartY, int cutWid
/// <param name="filename">保存路径</param>
/// <param name="quality">质量</param>
/// <returns>是否保存成功</returns>
public
static
bool
SaveAsJPEG
(
Bitmap
bitmap
,
string
filename
,
int
quality
=
90
)
public
static
bool
SaveAsJPEG
(
Bitmap
bitmap
,
string
filename
,
int
quality
=
90
)
{
if
(
bitmap
!=
null
)
if
(
bitmap
!=
null
)
{
string
path
=
Path
.
GetDirectoryName
(
filename
);
if
(!
Directory
.
Exists
(
path
))
//创建文件夹
string
path
=
Path
.
GetDirectoryName
(
filename
);
if
(!
Directory
.
Exists
(
path
))
//创建文件夹
{
Directory
.
CreateDirectory
(
path
);
}
...
...
@@ -138,9 +138,9 @@ public static bool SaveAsJPEG(Bitmap bitmap, string filename, int quality=90)
ImageCodecInfo
[]
codecs
=
ImageCodecInfo
.
GetImageEncoders
();
ImageCodecInfo
ici
=
null
;
foreach
(
ImageCodecInfo
codec
in
codecs
)
foreach
(
ImageCodecInfo
codec
in
codecs
)
{
if
(
codec
.
MimeType
.
IndexOf
(
"jpeg"
)
>
-
1
)
if
(
codec
.
MimeType
.
IndexOf
(
"jpeg"
)
>
-
1
)
{
ici
=
codec
;
break
;
...
...
@@ -152,7 +152,7 @@ public static bool SaveAsJPEG(Bitmap bitmap, string filename, int quality=90)
}
EncoderParameters
encoderParams
=
new
EncoderParameters
();
encoderParams
.
Param
[
0
]
=
new
EncoderParameter
(
Encoder
.
Quality
,
(
long
)
quality
);
encoderParams
.
Param
[
0
]
=
new
EncoderParameter
(
Encoder
.
Quality
,
quality
);
if
(
ici
!=
null
)
{
bitmap
.
Save
(
filename
,
ici
,
encoderParams
);
...
...
DataEditorX/Common/MyPath.cs
View file @
44764797
...
...
@@ -5,17 +5,16 @@
* 时间: 10:26
*
*/
using
System
;
using
System.Text
;
using
System.Windows.Forms
;
namespace
System.IO
{
/// <summary>
/// 路径处理
/// </summary>
public
class
MyPath
{
/// <summary>
/// 路径处理
/// </summary>
public
class
MyPath
{
/// <summary>
/// 从相对路径获取真实路径
/// </summary>
...
...
@@ -30,68 +29,69 @@ public static string GetRealPath(string dir)
}
return
dir
;
}
/// <summary>
/// 合并路径
/// </summary>
/// <param name="paths"></param>
/// <returns></returns>
/// <summary>
/// 合并路径
/// </summary>
/// <param name="paths"></param>
/// <returns></returns>
public
static
string
Combine
(
params
string
[]
paths
)
{
if
(
paths
.
Length
==
0
)
{
throw
new
ArgumentException
(
"please input path"
);
}
else
{
StringBuilder
builder
=
new
StringBuilder
();
string
spliter
=
Path
.
DirectorySeparatorChar
.
ToString
();
string
firstPath
=
paths
[
0
];
if
(
firstPath
.
StartsWith
(
"HTTP"
,
StringComparison
.
OrdinalIgnoreCase
))
{
spliter
=
"/"
;
}
if
(!
firstPath
.
EndsWith
(
spliter
))
{
firstPath
+=
spliter
;
}
builder
.
Append
(
firstPath
);
for
(
int
i
=
1
;
i
<
paths
.
Length
;
i
++)
{
string
nextPath
=
paths
[
i
];
if
(
nextPath
.
StartsWith
(
"/"
)
||
nextPath
.
StartsWith
(
"\\"
))
{
nextPath
=
nextPath
.
Substring
(
1
);
}
if
(
i
!=
paths
.
Length
-
1
)
//not the last one
{
if
(
nextPath
.
EndsWith
(
"/"
)
||
nextPath
.
EndsWith
(
"\\"
))
{
nextPath
=
nextPath
.
Substring
(
0
,
nextPath
.
Length
-
1
)
+
spliter
;
}
else
{
nextPath
+=
spliter
;
}
}
builder
.
Append
(
nextPath
);
}
return
builder
.
ToString
();
}
}
{
if
(
paths
.
Length
==
0
)
{
throw
new
ArgumentException
(
"please input path"
);
}
else
{
StringBuilder
builder
=
new
StringBuilder
();
string
spliter
=
Path
.
DirectorySeparatorChar
.
ToString
();
string
firstPath
=
paths
[
0
];
if
(
firstPath
.
StartsWith
(
"HTTP"
,
StringComparison
.
OrdinalIgnoreCase
))
{
spliter
=
"/"
;
}
if
(!
firstPath
.
EndsWith
(
spliter
))
{
firstPath
+=
spliter
;
}
builder
.
Append
(
firstPath
);
for
(
int
i
=
1
;
i
<
paths
.
Length
;
i
++)
{
string
nextPath
=
paths
[
i
];
if
(
nextPath
.
StartsWith
(
"/"
)
||
nextPath
.
StartsWith
(
"\\"
))
{
nextPath
=
nextPath
.
Substring
(
1
);
}
if
(
i
!=
paths
.
Length
-
1
)
//not the last one
{
if
(
nextPath
.
EndsWith
(
"/"
)
||
nextPath
.
EndsWith
(
"\\"
))
{
nextPath
=
nextPath
.
Substring
(
0
,
nextPath
.
Length
-
1
)
+
spliter
;
}
else
{
nextPath
+=
spliter
;
}
}
builder
.
Append
(
nextPath
);
}
return
builder
.
ToString
();
}
}
/// <summary>
/// 检查目录是否合法
/// </summary>
/// <param name="dir">目录</param>
/// <param name="defalut">不合法时,采取的目录</param>
/// <returns></returns>
public
static
string
CheckDir
(
string
dir
,
string
defalut
)
public
static
string
CheckDir
(
string
dir
,
string
defalut
)
{
DirectoryInfo
fo
;
try
{
fo
=
new
DirectoryInfo
(
GetRealPath
(
dir
));
}
catch
{
catch
{
//路径不合法
fo
=
new
DirectoryInfo
(
defalut
);
}
...
...
@@ -110,7 +110,7 @@ public static string CheckDir(string dir,string defalut)
/// <param name="tag">前面</param>
/// <param name="lang"></param>
/// <returns></returns>
public
static
string
GetFileName
(
string
tag
,
string
lang
)
public
static
string
GetFileName
(
string
tag
,
string
lang
)
{
return
tag
+
"_"
+
lang
+
".txt"
;
}
...
...
DataEditorX/Common/MySortList.cs
View file @
44764797
using
System
;
using
System.Collections.Generic
;
using
System.Collections.Generic
;
namespace
DataEditorX
{
class
MyComparer
<
K
>
:
IComparer
<
K
>
{
public
int
Compare
(
K
x
,
K
y
)
{
return
1
;
//永远不等,允许重复
}
}
public
class
MySortList
<
K
,
V
>
:
SortedList
<
K
,
V
>
{
class
MyComparer
<
K
>
:
IComparer
<
K
>
{
public
int
Compare
(
K
x
,
K
y
)
{
return
1
;
//永远不等,允许重复
}
}
public
MySortList
():
base
(
new
MyComparer
<
K
>())
{
}
public
new
void
Add
(
K
key
,
V
value
)
{
//falg用于跳出函数
int
flag
=
0
;
//检查是否具备这个key,并且检查value是否重复
foreach
(
KeyValuePair
<
K
,
V
>
item
in
this
)
{
if
(
item
.
Key
.
ToString
()
==
key
.
ToString
()
&&
item
.
Value
.
ToString
()
==
value
.
ToString
())
{
flag
=
1
;
}
}
if
(
flag
==
1
)
public
class
MySortList
<
K
,
V
>
:
SortedList
<
K
,
V
>
{
public
MySortList
()
:
base
(
new
MyComparer
<
K
>())
{
}
public
new
void
Add
(
K
key
,
V
value
)
{
//falg用于跳出函数
int
flag
=
0
;
//检查是否具备这个key,并且检查value是否重复
foreach
(
KeyValuePair
<
K
,
V
>
item
in
this
)
{
if
(
item
.
Key
.
ToString
()
==
key
.
ToString
()
&&
item
.
Value
.
ToString
()
==
value
.
ToString
())
{
flag
=
1
;
}
}
if
(
flag
==
1
)
{
return
;
//跳出函数
}
//否则就加入
base
.
Add
(
key
,
value
);
}
}
}
}
}
DataEditorX/Common/MyUtils.cs
View file @
44764797
...
...
@@ -6,47 +6,47 @@
*
* 要改变这种模板请点击 工具|选项|代码编写|编辑标准头文件
*/
using
System
;
using
System.Text
;
using
System.IO
;
using
System.Text
;
namespace
DataEditorX.Common
{
/// <summary>
/// Description of MyUtils.
/// </summary>
public
class
MyUtils
{
/// <summary>
/// 计算文件的MD5校验
/// </summary>
/// <param name="fileName"></param>
/// <returns></returns>
public
static
string
GetMD5HashFromFile
(
string
fileName
)
{
try
{
FileStream
file
=
new
FileStream
(
fileName
,
FileMode
.
Open
);
System
.
Security
.
Cryptography
.
MD5
md5
=
new
System
.
Security
.
Cryptography
.
MD5CryptoServiceProvider
();
byte
[]
retVal
=
md5
.
ComputeHash
(
file
);
file
.
Close
();
/// <summary>
/// Description of MyUtils.
/// </summary>
public
class
MyUtils
{
/// <summary>
/// 计算文件的MD5校验
/// </summary>
/// <param name="fileName"></param>
/// <returns></returns>
public
static
string
GetMD5HashFromFile
(
string
fileName
)
{
try
{
FileStream
file
=
new
FileStream
(
fileName
,
FileMode
.
Open
);
System
.
Security
.
Cryptography
.
MD5
md5
=
new
System
.
Security
.
Cryptography
.
MD5CryptoServiceProvider
();
byte
[]
retVal
=
md5
.
ComputeHash
(
file
);
file
.
Close
();
StringBuilder
sb
=
new
StringBuilder
();
for
(
int
i
=
0
;
i
<
retVal
.
Length
;
i
++)
{
sb
.
Append
(
retVal
[
i
].
ToString
(
"x2"
));
}
return
sb
.
ToString
();
}
catch
{
}
return
""
;
}
StringBuilder
sb
=
new
StringBuilder
();
for
(
int
i
=
0
;
i
<
retVal
.
Length
;
i
++)
{
sb
.
Append
(
retVal
[
i
].
ToString
(
"x2"
));
}
return
sb
.
ToString
();
}
catch
{
}
return
""
;
}
public
static
bool
Md5isEmpty
(
string
md5
){
return
md5
==
null
||
md5
.
Length
<
16
;
}
}
public
static
bool
Md5isEmpty
(
string
md5
)
{
return
md5
==
null
||
md5
.
Length
<
16
;
}
}
}
DataEditorX/Common/StrUtil.cs
View file @
44764797
using
System
;
using
System.Collections.Generic
;
using
System.Text
;
using
System.Text
;
namespace
DataEditorX.Common
{
public
class
StrUtil
{
public
static
string
AutoEnter
(
string
str
,
int
lineNum
,
char
re
)
{
if
(
str
==
null
||
str
.
Length
==
0
)
public
class
StrUtil
{
public
static
string
AutoEnter
(
string
str
,
int
lineNum
,
char
re
)
{
if
(
str
==
null
||
str
.
Length
==
0
)
{
return
""
;
}
str
=
" "
+
str
.
Replace
(
"\r\n"
,
"\n"
);
char
[]
ch
=
str
.
ToCharArray
();
str
=
" "
+
str
.
Replace
(
"\r\n"
,
"\n"
);
char
[]
ch
=
str
.
ToCharArray
();
_
=
ch
.
Length
;
StringBuilder
sb
=
new
StringBuilder
();
int
i
=
0
;
foreach
(
char
c
in
ch
)
{
int
ic
=
c
;
if
(
ic
>
128
)
int
i
=
0
;
foreach
(
char
c
in
ch
)
{
int
ic
=
c
;
if
(
ic
>
128
)
{
i
+=
2
;
}
...
...
@@ -33,25 +31,27 @@ public static string AutoEnter(string str, int lineNum, char re)
}
if
(
c
==
'\n'
||
c
==
'\r'
)
{
sb
.
Append
(
re
);
i
=
0
;
}
else
if
(
c
==
re
)
{
sb
.
Append
(
c
);
i
=
0
;
}
else
if
(
i
>=
lineNum
)
{
sb
.
Append
(
c
);
sb
.
Append
(
re
);
i
=
0
;
}
else
{
sb
.
Append
(
c
);
}
}
return
sb
.
ToString
();
}
}
{
sb
.
Append
(
re
);
i
=
0
;
}
else
if
(
c
==
re
)
{
sb
.
Append
(
c
);
i
=
0
;
}
else
if
(
i
>=
lineNum
)
{
sb
.
Append
(
c
);
sb
.
Append
(
re
);
i
=
0
;
}
else
{
sb
.
Append
(
c
);
}
}
return
sb
.
ToString
();
}
}
}
DataEditorX/Common/User32.cs
View file @
44764797
/*
* 由SharpDevelop创建。
* 用户: Acer
* 日期: 2014-10-25
* 时间: 21:30
*
*/
using
System
;
/*
* 由SharpDevelop创建。
* 用户: Acer
* 日期: 2014-10-25
* 时间: 21:30
*
*/
using
System.Runtime.InteropServices
;
namespace
System
...
...
DataEditorX/Common/XMLReader.cs
View file @
44764797
using
System
;
using
System
.Windows.Forms
;
using
System.Xml
;
using
System.IO
;
using
DataEditorX.Common
;
using
System.Windows.Forms
;
using
System.Diagnostics
;
using
System.Reflection
;
namespace
DataEditorX.Common
{
...
...
DataEditorX/Common/ZipStorer.cs
View file @
44764797
...
...
@@ -15,11 +15,13 @@ public class ZipStorer : IDisposable
/// <summary>
/// Compression method enumeration
/// </summary>
public
enum
Compression
:
ushort
{
public
enum
Compression
:
ushort
{
/// <summary>Uncompressed storage</summary>
Store
=
0
,
Store
=
0
,
/// <summary>Deflate compression method</summary>
Deflate
=
8
}
Deflate
=
8
}
#
region
ZipFileEntry
/// <summary>
...
...
@@ -28,7 +30,7 @@ public enum Compression : ushort {
public
struct
ZipFileEntry
{
/// <summary>Compression method</summary>
public
Compression
Method
;
public
Compression
Method
;
/// <summary>Full path and filename as stored in Zip</summary>
public
string
FilenameInZip
;
/// <summary>Original file size</summary>
...
...
@@ -151,7 +153,7 @@ public static ZipStorer Create(Stream _stream, string _comment)
/// <returns>A valid ZipStorer object</returns>
public
static
ZipStorer
Open
(
string
_filename
,
FileAccess
_access
)
{
Stream
stream
=
(
Stream
)
new
FileStream
(
_filename
,
FileMode
.
Open
,
_access
==
FileAccess
.
Read
?
FileAccess
.
Read
:
FileAccess
.
ReadWrite
);
Stream
stream
=
new
FileStream
(
_filename
,
FileMode
.
Open
,
_access
==
FileAccess
.
Read
?
FileAccess
.
Read
:
FileAccess
.
ReadWrite
);
ZipStorer
zip
=
Open
(
stream
,
_access
);
zip
.
fileName
=
_filename
;
...
...
@@ -185,7 +187,7 @@ public static ZipStorer Open(Stream _stream, FileAccess _access)
throw
new
InvalidDataException
();
}
/// <summary>
/// <summary>
/// Add full contents of a file into the Zip storage
/// </summary>
/// <param name="_method">Compression method</param>
...
...
@@ -194,7 +196,7 @@ public static ZipStorer Open(Stream _stream, FileAccess _access)
/// <param name="_comment">Comment for stored file</param>
public
void
AddFile
(
string
_pathname
,
string
_filenameInZip
,
string
_comment
)
{
Compression
_method
=
Compression
.
Deflate
;
Compression
_method
=
Compression
.
Deflate
;
if
(
this
.
access
==
FileAccess
.
Read
)
{
throw
new
InvalidOperationException
(
"Writing is not alowed"
);
...
...
@@ -237,7 +239,7 @@ public void AddStream(Compression _method, string _filenameInZip, Stream _source
throw
new
InvalidOperationException
(
"Writing is not alowed"
);
}
if
(
this
.
files
.
Count
==
0
)
if
(
this
.
files
.
Count
==
0
)
{
}
else
...
...
@@ -325,7 +327,7 @@ public List<ZipFileEntry> ReadCentralDir()
List
<
ZipFileEntry
>
result
=
new
List
<
ZipFileEntry
>();
for
(
int
pointer
=
0
;
pointer
<
this
.
centralDirImage
.
Length
;
)
for
(
int
pointer
=
0
;
pointer
<
this
.
centralDirImage
.
Length
;)
{
uint
signature
=
BitConverter
.
ToUInt32
(
this
.
centralDirImage
,
pointer
);
if
(
signature
!=
0x02014b50
)
...
...
@@ -401,7 +403,7 @@ public bool ExtractFile(ZipFileEntry _zfe, string _filename)
File
.
SetCreationTime
(
_filename
,
_zfe
.
ModifyTime
);
File
.
SetLastWriteTime
(
_filename
,
_zfe
.
ModifyTime
);
return
result
;
}
/// <summary>
...
...
@@ -561,7 +563,7 @@ private void WriteLocalHeader(ref ZipFileEntry _zfe)
Encoding
encoder
=
_zfe
.
EncodeUTF8
?
Encoding
.
UTF8
:
_defaultEncoding
;
byte
[]
encodedFilename
=
encoder
.
GetBytes
(
_zfe
.
FilenameInZip
);
this
.
zipFileStream
.
Write
(
new
byte
[]
{
80
,
75
,
3
,
4
,
20
,
0
},
0
,
6
);
// No extra header
this
.
zipFileStream
.
Write
(
new
byte
[]
{
80
,
75
,
3
,
4
,
20
,
0
},
0
,
6
);
// No extra header
this
.
zipFileStream
.
Write
(
BitConverter
.
GetBytes
((
ushort
)(
_zfe
.
EncodeUTF8
?
0x0800
:
0
)),
0
,
2
);
// filename and comment encoding
this
.
zipFileStream
.
Write
(
BitConverter
.
GetBytes
((
ushort
)
_zfe
.
Method
),
0
,
2
);
// zipping method
this
.
zipFileStream
.
Write
(
BitConverter
.
GetBytes
(
this
.
DateTimeToDosTime
(
_zfe
.
ModifyTime
)),
0
,
4
);
// zipping date and time
...
...
@@ -643,8 +645,8 @@ private void WriteEndRecord(uint _size, uint _offset)
byte
[]
encodedComment
=
encoder
.
GetBytes
(
this
.
comment
);
this
.
zipFileStream
.
Write
(
new
byte
[]
{
80
,
75
,
5
,
6
,
0
,
0
,
0
,
0
},
0
,
8
);
this
.
zipFileStream
.
Write
(
BitConverter
.
GetBytes
((
ushort
)
this
.
files
.
Count
+
this
.
existingFiles
),
0
,
2
);
this
.
zipFileStream
.
Write
(
BitConverter
.
GetBytes
((
ushort
)
this
.
files
.
Count
+
this
.
existingFiles
),
0
,
2
);
this
.
zipFileStream
.
Write
(
BitConverter
.
GetBytes
((
ushort
)
this
.
files
.
Count
+
this
.
existingFiles
),
0
,
2
);
this
.
zipFileStream
.
Write
(
BitConverter
.
GetBytes
((
ushort
)
this
.
files
.
Count
+
this
.
existingFiles
),
0
,
2
);
this
.
zipFileStream
.
Write
(
BitConverter
.
GetBytes
(
_size
),
0
,
4
);
this
.
zipFileStream
.
Write
(
BitConverter
.
GetBytes
(
_offset
),
0
,
4
);
this
.
zipFileStream
.
Write
(
BitConverter
.
GetBytes
((
ushort
)
encodedComment
.
Length
),
0
,
2
);
...
...
@@ -671,7 +673,7 @@ private void Store(ref ZipFileEntry _zfe, Stream _source)
}
_zfe
.
Crc32
=
0
^
0xffffffff
;
do
{
bytesRead
=
_source
.
Read
(
buffer
,
0
,
buffer
.
Length
);
...
...
@@ -721,8 +723,8 @@ private void Store(ref ZipFileEntry _zfe, Stream _source)
private
uint
DateTimeToDosTime
(
DateTime
_dt
)
{
return
(
uint
)(
(
_dt
.
Second
/
2
)
|
(
_dt
.
Minute
<<
5
)
|
(
_dt
.
Hour
<<
11
)
|
(
_dt
.
Day
<<
16
)
|
(
_dt
.
Month
<<
21
)
|
((
_dt
.
Year
-
1980
)
<<
25
));
(
_dt
.
Second
/
2
)
|
(
_dt
.
Minute
<<
5
)
|
(
_dt
.
Hour
<<
11
)
|
(
_dt
.
Day
<<
16
)
|
(
_dt
.
Month
<<
21
)
|
((
_dt
.
Year
-
1980
)
<<
25
));
}
private
DateTime
DosTimeToDateTime
(
uint
_dt
)
{
...
...
DataEditorX/Config/CodeConfig.cs
View file @
44764797
using
System
;
using
FastColoredTextBoxNS
;
using
System
;
using
System.Collections.Generic
;
using
System.IO
;
using
FastColoredTextBoxNS
;
namespace
DataEditorX.Config
{
/// <summary>
...
...
@@ -209,7 +208,7 @@ void AddToolIipDic(string key, string val)
nval
+=
Environment
.
NewLine
;
}
nval
+=
Environment
.
NewLine
+
val
;
nval
+=
Environment
.
NewLine
+
val
;
this
.
tooltipDic
[
skey
]
=
nval
;
}
else
...
...
DataEditorX/Config/DataConfig.cs
View file @
44764797
...
...
@@ -18,7 +18,7 @@ public class DataConfig
{
public
DataConfig
()
{
this
.
InitMember
(
MyPath
.
Combine
(
Application
.
StartupPath
,
MyConfig
.
TAG_CARDINFO
+
".txt"
));
this
.
InitMember
(
MyPath
.
Combine
(
Application
.
StartupPath
,
MyConfig
.
TAG_CARDINFO
+
".txt"
));
}
public
DataConfig
(
string
conf
)
{
...
...
@@ -31,7 +31,7 @@ public DataConfig(string conf)
public
void
InitMember
(
string
conf
)
{
//conf = MyPath.Combine(datapath, MyConfig.FILE_INFO);
if
(!
File
.
Exists
(
conf
))
if
(!
File
.
Exists
(
conf
))
{
this
.
dicCardRules
=
new
Dictionary
<
long
,
string
>();
this
.
dicSetnames
=
new
Dictionary
<
long
,
string
>();
...
...
@@ -54,7 +54,7 @@ public void InitMember(string conf)
this
.
dicCardRaces
=
DataManager
.
Read
(
text
,
MyConfig
.
TAG_RACE
);
this
.
dicCardLevels
=
DataManager
.
Read
(
text
,
MyConfig
.
TAG_LEVEL
);
}
}
/// <summary>
/// 规则
/// </summary>
...
...
DataEditorX/Config/DataManager.cs
View file @
44764797
...
...
@@ -6,11 +6,11 @@
*
*/
using
System
;
using
System.Collections.Generic
;
using
System.Globalization
;
using
System.IO
;
using
System.Text
;
using
System.Text.RegularExpressions
;
using
System.Globalization
;
using
System.Collections.Generic
;
namespace
DataEditorX.Config
{
...
...
@@ -42,7 +42,7 @@ public static string SubString(string content, string tag)
Match
mac
=
reg
.
Match
(
reReturn
(
content
));
if
(
mac
.
Success
)
//把相应的内容提取出来
{
return
mac
.
Groups
[
1
].
Value
.
Replace
(
"\n"
,
Environment
.
NewLine
);
return
mac
.
Groups
[
1
].
Value
.
Replace
(
"\n"
,
Environment
.
NewLine
);
}
return
""
;
}
...
...
@@ -57,7 +57,7 @@ public static string SubString(string content, string tag)
/// <returns></returns>
public
static
Dictionary
<
long
,
string
>
Read
(
string
content
,
string
tag
)
{
return
Read
(
SubString
(
content
,
tag
));
return
Read
(
SubString
(
content
,
tag
));
}
/// <summary>
/// 从文件读取内容,按行读取
...
...
@@ -122,7 +122,7 @@ public static string SubString(string content, string tag)
}
#
endregion
#
region
查找
public
static
List
<
long
>
GetKeys
(
Dictionary
<
long
,
string
>
dic
)
{
...
...
@@ -150,7 +150,7 @@ public static string[] GetValues(Dictionary<long, string> dic)
/// <returns></returns>
public
static
string
GetValue
(
Dictionary
<
long
,
string
>
dic
,
long
key
)
{
if
(
dic
.
ContainsKey
(
key
))
if
(
dic
.
ContainsKey
(
key
))
{
return
dic
[
key
].
Trim
();
}
...
...
DataEditorX/Config/ImageSet.cs
View file @
44764797
...
...
@@ -5,9 +5,6 @@
* 时间: 9:02
*
*/
using
System
;
using
System.Configuration
;
using
DataEditorX.Config
;
using
DataEditorX.Common
;
namespace
DataEditorX.Config
...
...
@@ -16,13 +13,14 @@ namespace DataEditorX.Config
/// 裁剪图片是、配置
/// </summary>
public
class
ImageSet
{
public
ImageSet
(){
{
public
ImageSet
()
{
this
.
Init
();
}
}
//初始化
void
Init
()
{
void
Init
()
{
this
.
normalArea
=
MyConfig
.
ReadArea
(
MyConfig
.
TAG_IMAGE_OTHER
);
this
.
xyzArea
=
MyConfig
.
ReadArea
(
MyConfig
.
TAG_IMAGE_XYZ
);
...
...
@@ -37,7 +35,7 @@ void Init()
this
.
H
=
ints
[
3
];
this
.
quilty
=
MyConfig
.
ReadInteger
(
MyConfig
.
TAG_IMAGE_QUILTY
,
95
);
}
}
/// <summary>
/// jpeg质量
/// </summary>
...
...
@@ -70,5 +68,5 @@ void Init()
/// p怪的中间图
/// </summary>
public
Area
pendulumArea
;
}
}
}
DataEditorX/Config/MyConfig.cs
View file @
44764797
using
System
;
using
System.Xml
;
using
System.IO
;
using
System.Globalization
;
using
DataEditorX.Common
;
using
System.Windows.Forms
;
using
DataEditorX.Common
;
using
System
;
using
System.Diagnostics
;
using
System.Globalization
;
using
System.IO
;
using
System.Reflection
;
using
System.Windows.Forms
;
namespace
DataEditorX.Config
{
...
...
@@ -88,10 +87,10 @@ public class MyConfig : XMLReader
/// 用本程序打开文件
/// </summary>
public
const
string
TAG_OPEN_IN_THIS
=
"open_file_in_this"
;
/// <summary>
/// 自动检查更新
/// </summary>
public
const
string
TAG_AUTO_CHECK_UPDATE
=
"auto_check_update"
;
/// <summary>
/// 自动检查更新
/// </summary>
public
const
string
TAG_AUTO_CHECK_UPDATE
=
"auto_check_update"
;
/// <summary>
/// add require automatically
/// </summary>
...
...
@@ -259,20 +258,22 @@ public static Area ReadArea(string key)
/// </summary>
/// <param name="key"></param>
/// <returns></returns>
public
static
bool
ReadBoolean
(
string
key
,
bool
def
=
false
)
public
static
bool
ReadBoolean
(
string
key
,
bool
def
=
false
)
{
string
val
=
ReadString
(
key
);
if
(
"true"
.
Equals
(
val
,
StringComparison
.
OrdinalIgnoreCase
)){
return
true
;
}
if
(
"false"
.
Equals
(
val
,
StringComparison
.
OrdinalIgnoreCase
)){
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
#
endregion
/// <summary>
/// 语言配置文件名
/// </summary>
...
...
@@ -280,27 +281,27 @@ public static bool ReadBoolean(string key,bool def=false)
/// <returns></returns>
public
static
string
GetLanguageFile
(
string
path
)
{
if
(
ReadBoolean
(
TAG_CHECK_SYSLANG
)
&&
Directory
.
Exists
(
path
))
{
Save
(
TAG_CHECK_SYSLANG
,
"false"
);
string
[]
words
=
CultureInfo
.
InstalledUICulture
.
EnglishName
.
Split
(
' '
);
string
syslang
=
words
[
0
];
string
[]
files
=
Directory
.
GetFiles
(
path
);
foreach
(
string
file
in
files
)
{
string
name
=
MyPath
.
GetFullFileName
(
TAG_LANGUAGE
,
file
);
if
(
string
.
IsNullOrEmpty
(
name
))
if
(
ReadBoolean
(
TAG_CHECK_SYSLANG
)
&&
Directory
.
Exists
(
path
))
{
Save
(
TAG_CHECK_SYSLANG
,
"false"
);
string
[]
words
=
CultureInfo
.
InstalledUICulture
.
EnglishName
.
Split
(
' '
);
string
syslang
=
words
[
0
];
string
[]
files
=
Directory
.
GetFiles
(
path
);
foreach
(
string
file
in
files
)
{
string
name
=
MyPath
.
GetFullFileName
(
TAG_LANGUAGE
,
file
);
if
(
string
.
IsNullOrEmpty
(
name
))
{
continue
;
}
if
(
syslang
.
Equals
(
name
,
StringComparison
.
OrdinalIgnoreCase
))
{
Save
(
TAG_LANGUAGE
,
syslang
);
break
;
}
}
}
{
Save
(
TAG_LANGUAGE
,
syslang
);
break
;
}
}
}
return
MyPath
.
Combine
(
path
,
MyPath
.
GetFileName
(
TAG_LANGUAGE
,
GetAppConfig
(
TAG_LANGUAGE
)));
}
/// <summary>
...
...
@@ -310,7 +311,7 @@ public static string GetLanguageFile(string path)
/// <returns></returns>
public
static
string
GetCardInfoFile
(
string
path
)
{
return
MyPath
.
Combine
(
path
,
MyPath
.
GetFileName
(
TAG_CARDINFO
,
GetAppConfig
(
TAG_LANGUAGE
)));
return
MyPath
.
Combine
(
path
,
MyPath
.
GetFileName
(
TAG_CARDINFO
,
GetAppConfig
(
TAG_LANGUAGE
)));
}
/// <summary>
/// 发送消息打开文件
...
...
DataEditorX/Config/YgoPath.cs
View file @
44764797
using
System
;
using
System.Collections.Generic
;
using
System.Text
;
using
System.IO
;
using
System.IO
;
namespace
DataEditorX.Config
{
...
...
@@ -20,7 +17,7 @@ public void SetPath(string gamepath)
this
.
luapath
=
MyPath
.
Combine
(
gamepath
,
"script"
);
this
.
ydkpath
=
MyPath
.
Combine
(
gamepath
,
"deck"
);
this
.
replaypath
=
MyPath
.
Combine
(
gamepath
,
"replay"
);
}
}
/// <summary>游戏目录</summary>
public
string
gamepath
;
/// <summary>大图目录</summary>
...
...
@@ -36,67 +33,67 @@ public void SetPath(string gamepath)
/// <summary>录像目录</summary>
public
string
replaypath
;
public
string
GetImage
(
long
id
)
public
string
GetImage
(
long
id
)
{
return
this
.
GetImage
(
id
.
ToString
());
}
//public string GetImageThum(long id)
//{
// return GetImageThum(id.ToString());
//}
public
string
GetImageField
(
long
id
)
{
return
this
.
GetImageField
(
id
.
ToString
());
//场地图
}
public
string
GetScript
(
long
id
)
{
return
this
.
GetImage
(
id
.
ToString
());
}
//public string GetImageThum(long id)
//{
// return GetImageThum(id.ToString());
//}
public
string
GetImageField
(
long
id
)
return
this
.
GetScript
(
id
.
ToString
());
}
public
string
GetYdk
(
string
name
)
{
return
this
.
GetImageField
(
id
.
ToString
());
//场地图
return
MyPath
.
Combine
(
this
.
ydkpath
,
name
+
".ydk"
);
}
public
string
GetScript
(
long
id
)
//字符串id
public
string
GetImage
(
string
id
)
{
return
this
.
GetScript
(
id
.
ToString
());
}
public
string
GetYdk
(
string
name
)
{
return
MyPath
.
Combine
(
this
.
ydkpath
,
name
+
".ydk"
);
}
//字符串id
public
string
GetImage
(
string
id
)
{
return
MyPath
.
Combine
(
this
.
picpath
,
id
+
".jpg"
);
}
//public string GetImageThum(string id)
//{
// return MyPath.Combine(picpath2, id + ".jpg");
//}
public
string
GetImageField
(
string
id
)
return
MyPath
.
Combine
(
this
.
picpath
,
id
+
".jpg"
);
}
//public string GetImageThum(string id)
//{
// return MyPath.Combine(picpath2, id + ".jpg");
//}
public
string
GetImageField
(
string
id
)
{
return
MyPath
.
Combine
(
this
.
fieldpath
,
id
+
".png"
);
//场地图
return
MyPath
.
Combine
(
this
.
fieldpath
,
id
+
".png"
);
//场地图
}
public
string
GetScript
(
string
id
)
{
return
MyPath
.
Combine
(
this
.
luapath
,
"c"
+
id
+
".lua"
);
}
public
string
GetModuleScript
(
string
modulescript
)
{
return
MyPath
.
Combine
(
this
.
luapath
,
modulescript
+
".lua"
);
}
public
string
GetScript
(
string
id
)
{
return
MyPath
.
Combine
(
this
.
luapath
,
"c"
+
id
+
".lua"
);
}
public
string
GetModuleScript
(
string
modulescript
)
{
return
MyPath
.
Combine
(
this
.
luapath
,
modulescript
+
".lua"
);
}
public
string
[]
GetCardfiles
(
long
id
)
{
string
[]
files
=
new
string
[]{
public
string
[]
GetCardfiles
(
long
id
)
{
string
[]
files
=
new
string
[]{
this
.
GetImage
(
id
),
//大图
//GetImageThum(id),//小图
this
.
GetImageField
(
id
),
//场地图
this
.
GetScript
(
id
)
};
return
files
;
}
public
string
[]
GetCardfiles
(
string
id
)
{
string
[]
files
=
new
string
[]{
};
return
files
;
}
public
string
[]
GetCardfiles
(
string
id
)
{
string
[]
files
=
new
string
[]{
this
.
GetImage
(
id
),
//大图
//GetImageThum(id),//小图
this
.
GetImageField
(
id
),
//场地图
this
.
GetScript
(
id
)
};
return
files
;
}
}
};
return
files
;
}
}
}
DataEditorX/Controls/DFlowLayoutPanel.cs
View file @
44764797
using
System
;
using
System.Collections.Generic
;
using
System.Text
;
using
System.Windows.Forms
;
using
System.Windows.Forms
;
namespace
DataEditorX
{
...
...
DataEditorX/Controls/DListBox.cs
View file @
44764797
using
System
;
using
System.Collections.Generic
;
using
System.Text
;
using
System.Windows.Forms
;
using
System.Windows.Forms
;
namespace
DataEditorX
{
...
...
DataEditorX/Controls/DListView.cs
View file @
44764797
using
System
;
using
System.Collections.Generic
;
using
System.Text
;
using
System.Windows.Forms
;
using
System.Windows.Forms
;
namespace
DataEditorX
{
...
...
DataEditorX/Controls/FastColoredTextBoxEx.cs
View file @
44764797
...
...
@@ -7,20 +7,17 @@
*/
using
System
;
using
System.Drawing
;
using
System.Drawing.Drawing2D
;
using
System.Windows.Forms
;
using
System.Collections.Generic
;
using
System.Text
;
namespace
FastColoredTextBoxNS
{
public
class
FastColoredTextBoxEx
:
FastColoredTextBox
public
class
FastColoredTextBoxEx
:
FastColoredTextBox
{
public
Label
lbTooltip
;
Point
lastMouseCoord
;
public
FastColoredTextBoxEx
()
:
base
()
{
public
FastColoredTextBoxEx
()
:
base
()
{
this
.
SyntaxHighlighter
=
new
MySyntaxHighlighter
();
this
.
TextChanged
+=
this
.
FctbTextChanged
;
this
.
ToolTipDelay
=
1
;
...
...
@@ -30,15 +27,15 @@ public FastColoredTextBoxEx() : base()
}
public
new
event
EventHandler
<
ToolTipNeededEventArgs
>
ToolTipNeeded
;
protected
override
void
OnMouseMove
(
MouseEventArgs
e
)
{
base
.
OnMouseMove
(
e
);
protected
override
void
OnMouseMove
(
MouseEventArgs
e
)
{
base
.
OnMouseMove
(
e
);
this
.
lastMouseCoord
=
e
.
Location
;
}
//函数悬停提示
protected
override
void
OnToolTip
()
{
if
(
this
.
ToolTip
==
null
)
}
//函数悬停提示
protected
override
void
OnToolTip
()
{
if
(
this
.
ToolTip
==
null
)
{
return
;
}
...
...
@@ -51,36 +48,36 @@ protected override void OnToolTip()
//get place under mouse
Place
place
=
this
.
PointToPlace
(
this
.
lastMouseCoord
);
//check distance
Point
p
=
this
.
PlaceToPoint
(
place
);
if
(
Math
.
Abs
(
p
.
X
-
this
.
lastMouseCoord
.
X
)
>
this
.
CharWidth
*
2
||
Math
.
Abs
(
p
.
Y
-
this
.
lastMouseCoord
.
Y
)
>
this
.
CharHeight
*
2
)
//check distance
Point
p
=
this
.
PlaceToPoint
(
place
);
if
(
Math
.
Abs
(
p
.
X
-
this
.
lastMouseCoord
.
X
)
>
this
.
CharWidth
*
2
||
Math
.
Abs
(
p
.
Y
-
this
.
lastMouseCoord
.
Y
)
>
this
.
CharHeight
*
2
)
{
return
;
}
//get word under mouse
var
r
=
new
Range
(
this
,
place
,
place
);
string
hoveredWord
=
r
.
GetFragment
(
"[a-zA-Z0-9_]"
).
Text
;
//event handler
var
ea
=
new
ToolTipNeededEventArgs
(
place
,
hoveredWord
);
ToolTipNeeded
(
this
,
ea
);
string
hoveredWord
=
r
.
GetFragment
(
"[a-zA-Z0-9_]"
).
Text
;
//event handler
var
ea
=
new
ToolTipNeededEventArgs
(
place
,
hoveredWord
);
ToolTipNeeded
(
this
,
ea
);
if
(
ea
.
ToolTipText
!=
null
)
{
if
(
ea
.
ToolTipText
!=
null
)
{
this
.
ShowTooltipWithLabel
(
ea
.
ToolTipTitle
,
ea
.
ToolTipText
);
}
}
public
void
ShowTooltipWithLabel
(
string
title
,
string
text
,
int
height
)
{
lbTooltip
.
Visible
=
true
;
lbTooltip
.
Text
=
$"
{
title
}
\r\n\r\n
{
text
}
"
;
lbTooltip
.
Location
=
new
Point
(
this
.
Size
.
Width
-
500
,
height
);
this
.
lbTooltip
.
Visible
=
true
;
this
.
lbTooltip
.
Text
=
$"
{
title
}
\r\n\r\n
{
text
}
"
;
this
.
lbTooltip
.
Location
=
new
Point
(
this
.
Size
.
Width
-
500
,
height
);
}
public
void
ShowTooltipWithLabel
(
string
title
,
string
text
)
{
this
.
ShowTooltipWithLabel
(
title
,
text
,
this
.
lastMouseCoord
.
Y
+
this
.
CharHeight
);
this
.
ShowTooltipWithLabel
(
title
,
text
,
this
.
lastMouseCoord
.
Y
+
this
.
CharHeight
);
}
//高亮当前词
...
...
@@ -127,7 +124,7 @@ private void InitializeComponent()
//
this
.
lbTooltip
.
AutoSize
=
true
;
this
.
lbTooltip
.
BackColor
=
SystemColors
.
Desktop
;
this
.
lbTooltip
.
Font
=
new
Font
(
"微软雅黑"
,
15.75F
,
FontStyle
.
Regular
,
GraphicsUnit
.
Point
,
((
byte
)(
0
))
);
this
.
lbTooltip
.
Font
=
new
Font
(
"微软雅黑"
,
15.75F
,
FontStyle
.
Regular
,
GraphicsUnit
.
Point
,
0
);
this
.
lbTooltip
.
ForeColor
=
SystemColors
.
Control
;
this
.
lbTooltip
.
Location
=
new
Point
(
221
,
117
);
this
.
lbTooltip
.
MaximumSize
=
new
Size
(
480
,
0
);
...
...
@@ -157,7 +154,7 @@ private void FastColoredTextBoxEx_Load(object sender, EventArgs e)
private
void
lbTooltip_MouseMove
(
object
sender
,
MouseEventArgs
e
)
{
lbTooltip
.
Visible
=
false
;
this
.
lbTooltip
.
Visible
=
false
;
}
}
}
DataEditorX/Controls/History.cs
View file @
44764797
using
System
;
using
DataEditorX.Config
;
using
DataEditorX.Core
;
using
DataEditorX.Language
;
using
System
;
using
System.Collections.Generic
;
using
System.IO
;
using
DataEditorX.Core
;
using
DataEditorX.Config
;
using
System.Windows.Forms
;
using
DataEditorX.Language
;
namespace
DataEditorX.Controls
{
...
...
@@ -108,7 +108,7 @@ void SaveHistory()
texts
+=
Environment
.
NewLine
+
str
;
}
}
if
(
File
.
Exists
(
this
.
historyFile
))
if
(
File
.
Exists
(
this
.
historyFile
))
{
File
.
Delete
(
this
.
historyFile
);
}
...
...
@@ -143,7 +143,7 @@ public void MenuHistory()
tsmiclear2
.
Click
+=
this
.
MenuHistoryClear2_Click
;
this
.
mainForm
.
AddLuaMenu
(
tsmiclear2
);
}
void
MenuHistoryClear2_Click
(
object
sender
,
EventArgs
e
)
{
this
.
luahistory
.
Clear
();
...
...
DataEditorX/Controls/IEditForm.cs
View file @
44764797
using
System
;
using
System.Collections.Generic
;
using
System.Text
;
namespace
DataEditorX.Controls
namespace
DataEditorX.Controls
{
public
interface
IEditForm
{
...
...
DataEditorX/Controls/MySyntaxHighlighter.cs
View file @
44764797
...
...
@@ -5,13 +5,7 @@
* 时间: 23:14
*
*/
using
System
;
using
System.Collections.Generic
;
using
System.Drawing
;
using
System.Globalization
;
using
System.IO
;
using
System.Text.RegularExpressions
;
using
System.Xml
;
namespace
FastColoredTextBoxNS
{
...
...
@@ -20,14 +14,14 @@ namespace FastColoredTextBoxNS
/// </summary>
public
class
MySyntaxHighlighter
:
SyntaxHighlighter
{
readonly
TextStyle
mNumberStyle
=
new
TextStyle
(
Brushes
.
Orange
,
null
,
FontStyle
.
Regular
);
readonly
TextStyle
mStrStyle
=
new
TextStyle
(
Brushes
.
Gold
,
null
,
FontStyle
.
Regular
);
readonly
TextStyle
conStyle
=
new
TextStyle
(
Brushes
.
YellowGreen
,
null
,
FontStyle
.
Regular
);
readonly
TextStyle
mKeywordStyle
=
new
TextStyle
(
Brushes
.
DeepSkyBlue
,
null
,
FontStyle
.
Regular
);
readonly
TextStyle
mGrayStyle
=
new
TextStyle
(
Brushes
.
Gray
,
null
,
FontStyle
.
Regular
);
readonly
TextStyle
mFunStyle
=
new
TextStyle
(
Brushes
.
LightGray
,
null
,
FontStyle
.
Bold
);
readonly
TextStyle
mNumberStyle
=
new
TextStyle
(
Brushes
.
Orange
,
null
,
FontStyle
.
Regular
);
readonly
TextStyle
mStrStyle
=
new
TextStyle
(
Brushes
.
Gold
,
null
,
FontStyle
.
Regular
);
readonly
TextStyle
conStyle
=
new
TextStyle
(
Brushes
.
YellowGreen
,
null
,
FontStyle
.
Regular
);
readonly
TextStyle
mKeywordStyle
=
new
TextStyle
(
Brushes
.
DeepSkyBlue
,
null
,
FontStyle
.
Regular
);
readonly
TextStyle
mGrayStyle
=
new
TextStyle
(
Brushes
.
Gray
,
null
,
FontStyle
.
Regular
);
readonly
TextStyle
mFunStyle
=
new
TextStyle
(
Brushes
.
LightGray
,
null
,
FontStyle
.
Bold
);
/// <summary>
/// Highlights Lua code
/// </summary>
...
...
@@ -47,28 +41,28 @@ public override void LuaSyntaxHighlight(Range range)
//clear style of changed range
range
.
ClearStyle
(
this
.
mStrStyle
,
this
.
mGrayStyle
,
this
.
conStyle
,
this
.
mNumberStyle
,
this
.
mKeywordStyle
,
this
.
mFunStyle
);
//
if
(
LuaStringRegex
==
null
)
{
InitLuaRegex
();
}
//string highlighting
range
.
SetStyle
(
this
.
mStrStyle
,
LuaStringRegex
);
if
(
this
.
LuaStringRegex
==
null
)
{
this
.
InitLuaRegex
();
}
//string highlighting
range
.
SetStyle
(
this
.
mStrStyle
,
this
.
LuaStringRegex
);
//comment highlighting
range
.
SetStyle
(
this
.
mGrayStyle
,
LuaCommentRegex1
);
range
.
SetStyle
(
this
.
mGrayStyle
,
LuaCommentRegex2
);
range
.
SetStyle
(
this
.
mGrayStyle
,
LuaCommentRegex3
);
range
.
SetStyle
(
this
.
mGrayStyle
,
this
.
LuaCommentRegex1
);
range
.
SetStyle
(
this
.
mGrayStyle
,
this
.
LuaCommentRegex2
);
range
.
SetStyle
(
this
.
mGrayStyle
,
this
.
LuaCommentRegex3
);
//number highlighting
range
.
SetStyle
(
this
.
mNumberStyle
,
LuaNumberRegex
);
range
.
SetStyle
(
this
.
mNumberStyle
,
this
.
LuaNumberRegex
);
//keyword highlighting
range
.
SetStyle
(
this
.
mKeywordStyle
,
LuaKeywordRegex
);
range
.
SetStyle
(
this
.
mKeywordStyle
,
this
.
LuaKeywordRegex
);
//functions highlighting
range
.
SetStyle
(
this
.
mFunStyle
,
LuaFunctionsRegex
);
range
.
SetStyle
(
this
.
mFunStyle
,
this
.
LuaFunctionsRegex
);
range
.
SetStyle
(
this
.
mNumberStyle
,
@"\bc\d+\b"
);
range
.
SetStyle
(
this
.
conStyle
,
@"[\s|\(|+|,]{0,1}(?<range>[A-Z_]+?)[\)|+|\s|,|;]"
);
//range.SetStyle(mFunStyle, @"[:|\.|\s](?<range>[a-zA-Z0-9_]*?)[\(|\)|\s]");
//clear folding markers
range
.
ClearFoldingMarkers
();
//set folding markers
...
...
DataEditorX/Core/Card.cs
View file @
44764797
...
...
@@ -3,26 +3,26 @@
* desc :卡片类
* ModiftyDate :2014-02-12
*/
using
DataEditorX.Core.Info
;
using
System
;
using
System.Globalization
;
using
System.Text.RegularExpressions
;
using
DataEditorX.Core.Info
;
namespace
DataEditorX.Core
{
public
struct
Card
:
IEquatable
<
Card
>
{
public
struct
Card
:
IEquatable
<
Card
>
{
public
const
int
STR_MAX
=
0x10
;
public
const
int
SETCODE_MAX
=
4
;
#
region
构造
/// <summary>
/// 卡片
/// </summary>
/// <param name="cardCode">密码</param>
/// <param name="cardName">名字</param>
public
Card
(
long
cardCode
)
{
#
region
构造
/// <summary>
/// 卡片
/// </summary>
/// <param name="cardCode">密码</param>
/// <param name="cardName">名字</param>
public
Card
(
long
cardCode
)
{
this
.
id
=
cardCode
;
this
.
name
=
""
;
this
.
ot
=
0
;
...
...
@@ -42,56 +42,57 @@ public Card(long cardCode)
this
.
str
[
i
]
=
""
;
}
}
#
endregion
#
endregion
#
region
成员
/// <summary>卡片密码</summary>
public
long
id
;
/// <summary>卡片规则</summary>
public
int
ot
;
/// <summary>卡片同名卡</summary>
public
long
alias
;
/// <summary>卡片系列号</summary>
public
long
setcode
;
/// <summary>卡片种类</summary>
public
long
type
;
/// <summary>攻击力</summary>
public
int
atk
;
/// <summary>防御力</summary>
public
int
def
;
/// <summary>卡片等级</summary>
public
long
level
;
/// <summary>卡片种族</summary>
public
long
race
;
/// <summary>卡片属性</summary>
public
int
attribute
;
/// <summary>效果种类</summary>
public
long
category
;
/// <summary>卡片名称</summary>
public
string
name
;
/// <summary>描述文本</summary>
public
string
desc
;
#
region
成员
/// <summary>卡片密码</summary>
public
long
id
;
/// <summary>卡片规则</summary>
public
int
ot
;
/// <summary>卡片同名卡</summary>
public
long
alias
;
/// <summary>卡片系列号</summary>
public
long
setcode
;
/// <summary>卡片种类</summary>
public
long
type
;
/// <summary>攻击力</summary>
public
int
atk
;
/// <summary>防御力</summary>
public
int
def
;
/// <summary>卡片等级</summary>
public
long
level
;
/// <summary>卡片种族</summary>
public
long
race
;
/// <summary>卡片属性</summary>
public
int
attribute
;
/// <summary>效果种类</summary>
public
long
category
;
/// <summary>卡片名称</summary>
public
string
name
;
/// <summary>描述文本</summary>
public
string
desc
;
string
[]
str
;
/// <summary>脚本文件文字</summary>
/// <summary>脚本文件文字</summary>
public
string
[]
Str
{
get
{
get
{
if
(
this
.
str
==
null
)
{
this
.
str
=
new
string
[
STR_MAX
];
for
(
int
i
=
0
;
i
<
STR_MAX
;
i
++)
{
this
.
str
=
new
string
[
STR_MAX
];
for
(
int
i
=
0
;
i
<
STR_MAX
;
i
++)
{
this
.
str
[
i
]
=
""
;
}
}
return
this
.
str
;
}
}
set
{
this
.
str
=
value
;
}
}
public
long
[]
GetSetCode
()
{
long
[]
setcodes
=
new
long
[
SETCODE_MAX
];
for
(
int
i
=
0
,
k
=
0
;
i
<
SETCODE_MAX
;
k
+=
0x10
,
i
++)
for
(
int
i
=
0
,
k
=
0
;
i
<
SETCODE_MAX
;
k
+=
0x10
,
i
++)
{
setcodes
[
i
]
=
(
this
.
setcode
>>
k
)
&
0xffff
;
}
...
...
@@ -124,25 +125,25 @@ public void SetSetCode(params string[] setcodes)
}
}
}
public
long
GetLeftScale
()
{
return
(
this
.
level
>>
24
)
&
0xff
;
}
public
long
GetRightScale
()
{
return
(
this
.
level
>>
16
)
&
0xff
;
}
public
long
GetLeftScale
()
{
return
(
this
.
level
>>
24
)
&
0xff
;
}
public
long
GetRightScale
()
{
return
(
this
.
level
>>
16
)
&
0xff
;
}
#
endregion
#
region
比较、哈希值、操作符
/// <summary>
/// 比较
/// </summary>
/// <param name="obj">对象</param>
/// <returns>结果</returns>
public
override
bool
Equals
(
object
obj
)
{
if
(
obj
is
Card
)
#
region
比较、哈希值、操作符
/// <summary>
/// 比较
/// </summary>
/// <param name="obj">对象</param>
/// <returns>结果</returns>
public
override
bool
Equals
(
object
obj
)
{
if
(
obj
is
Card
)
{
return
this
.
Equals
((
Card
)
obj
);
// use Equals method below
}
...
...
@@ -151,15 +152,15 @@ public override bool Equals(object obj)
return
false
;
}
}
/// <summary>
/// 比较卡片,除脚本提示文本
/// </summary>
/// <param name="other"></param>
/// <returns></returns>
/// <summary>
/// 比较卡片,除脚本提示文本
/// </summary>
/// <param name="other"></param>
/// <returns></returns>
public
bool
EqualsData
(
Card
other
)
{
bool
equalBool
=
true
;
if
(
this
.
id
!=
other
.
id
)
{
bool
equalBool
=
true
;
if
(
this
.
id
!=
other
.
id
)
{
equalBool
=
false
;
}
...
...
@@ -213,16 +214,16 @@ public bool EqualsData(Card other)
}
return
equalBool
;
}
/// <summary>
/// 比较卡片是否一致?
/// </summary>
/// <param name="other">比较的卡片</param>
/// <returns>结果</returns>
public
bool
Equals
(
Card
other
)
{
bool
equalBool
=
this
.
EqualsData
(
other
);
if
(!
equalBool
)
}
/// <summary>
/// 比较卡片是否一致?
/// </summary>
/// <param name="other">比较的卡片</param>
/// <returns>结果</returns>
public
bool
Equals
(
Card
other
)
{
bool
equalBool
=
this
.
EqualsData
(
other
);
if
(!
equalBool
)
{
return
false
;
}
...
...
@@ -231,56 +232,57 @@ public bool Equals(Card other)
equalBool
=
false
;
}
else
{
int
l
=
this
.
str
.
Length
;
for
(
int
i
=
0
;
i
<
l
;
i
++)
{
if
(!
this
.
str
[
i
].
Equals
(
other
.
str
[
i
]))
{
equalBool
=
false
;
break
;
}
}
}
return
equalBool
;
{
int
l
=
this
.
str
.
Length
;
for
(
int
i
=
0
;
i
<
l
;
i
++)
{
if
(!
this
.
str
[
i
].
Equals
(
other
.
str
[
i
]))
{
equalBool
=
false
;
break
;
}
}
}
return
equalBool
;
}
/// <summary>
/// 得到哈希值
/// </summary>
public
override
int
GetHashCode
()
{
// combine the hash codes of all members here (e.g. with XOR operator ^)
int
hashCode
=
this
.
id
.
GetHashCode
()
+
this
.
name
.
GetHashCode
();
return
hashCode
;
//member.GetHashCode();
}
/// <summary>
/// 比较卡片是否相等
/// </summary>
public
static
bool
operator
==(
Card
left
,
Card
right
)
{
return
left
.
Equals
(
right
);
}
}
/// <summary>
/// 得到哈希值
/// </summary>
public
override
int
GetHashCode
()
{
// combine the hash codes of all members here (e.g. with XOR operator ^)
int
hashCode
=
this
.
id
.
GetHashCode
()
+
this
.
name
.
GetHashCode
();
return
hashCode
;
//member.GetHashCode();
}
/// <summary>
/// 比较卡片是否相等
/// </summary>
public
static
bool
operator
==(
Card
left
,
Card
right
)
{
return
left
.
Equals
(
right
);
}
/// <summary>
/// 是否是某类型
/// </summary>
/// <param name="type"></param>
/// <returns></returns>
public
bool
IsType
(
CardType
type
){
if
((
this
.
type
&
(
long
)
type
)
==
(
long
)
type
)
public
bool
IsType
(
CardType
type
)
{
if
((
this
.
type
&
(
long
)
type
)
==
(
long
)
type
)
{
return
true
;
}
return
false
;
}
}
/// <summary>
/// 是否是某系列
/// </summary>
/// <param name="sc"></param>
/// <returns></returns>
public
bool
IsSetCode
(
long
sc
)
{
{
long
settype
=
sc
&
0xfff
;
long
setsubtype
=
sc
&
0xf000
;
long
setcode
=
this
.
setcode
;
...
...
@@ -294,15 +296,15 @@ public bool IsSetCode(long sc)
setcode
>>=
0x10
;
}
return
false
;
}
/// <summary>
/// 卡片是否不相等
/// </summary>
public
static
bool
operator
!=(
Card
left
,
Card
right
)
{
return
!
left
.
Equals
(
right
);
}
#
endregion
}
/// <summary>
/// 卡片是否不相等
/// </summary>
public
static
bool
operator
!=(
Card
left
,
Card
right
)
{
return
!
left
.
Equals
(
right
);
}
#
endregion
#
region
卡片文字信息
/// <summary>
...
...
@@ -318,22 +320,26 @@ public string IdString
public
override
string
ToString
()
{
string
str
;
if
(
this
.
IsType
(
CardType
.
TYPE_MONSTER
)){
if
(
this
.
IsType
(
CardType
.
TYPE_MONSTER
))
{
str
=
this
.
name
+
"["
+
this
.
IdString
+
"]\n["
+
YGOUtil
.
GetTypeString
(
this
.
type
)
+
"] "
+
YGOUtil
.
GetRace
(
this
.
race
)
+
"/"
+
YGOUtil
.
GetAttributeString
(
this
.
attribute
)
+
"\n"
+
this
.
levelString
()
+
" "
+
this
.
atk
+
"/"
+
this
.
def
+
"\n"
+
this
.
redesc
();
}
else
}
else
{
str
=
this
.
name
+
"["
+
this
.
IdString
+
"]\n["
+
YGOUtil
.
GetTypeString
(
this
.
type
)+
"]\n"
+
this
.
redesc
();
str
=
this
.
name
+
"["
+
this
.
IdString
+
"]\n["
+
YGOUtil
.
GetTypeString
(
this
.
type
)
+
"]\n"
+
this
.
redesc
();
}
return
str
;
}
public
string
ToShortString
(){
return
this
.
name
+
" ["
+
this
.
IdString
+
"]"
;
public
string
ToShortString
()
{
return
this
.
name
+
" ["
+
this
.
IdString
+
"]"
;
}
public
string
ToLongString
(){
public
string
ToLongString
()
{
return
this
.
ToString
();
}
...
...
@@ -362,5 +368,5 @@ string redesc()
}
#
endregion
}
}
DataEditorX/Core/CardEdit.cs
View file @
44764797
using
System
;
using
DataEditorX.Config
;
using
DataEditorX.Language
;
using
System.Collections.Generic
;
using
System.Text
;
using
System.IO
;
using
DataEditorX.Config
;
using
DataEditorX.Language
;
using
DataEditorX.Core.Info
;
using
System.Text
;
namespace
DataEditorX.Core
{
public
class
CardEdit
{
readonly
IDataForm
dataform
;
public
AddCommand
addCard
;
public
ModCommand
modCard
;
public
DelCommand
delCard
;
public
CopyCommand
copyCard
;
public
AddCommand
addCard
;
public
ModCommand
modCard
;
public
DelCommand
delCard
;
public
CopyCommand
copyCard
;
public
CardEdit
(
IDataForm
dataform
)
{
this
.
dataform
=
dataform
;
this
.
addCard
=
new
AddCommand
(
this
);
this
.
modCard
=
new
ModCommand
(
this
);
this
.
delCard
=
new
DelCommand
(
this
);
this
.
copyCard
=
new
CopyCommand
(
this
);
this
.
addCard
=
new
AddCommand
(
this
);
this
.
modCard
=
new
ModCommand
(
this
);
this
.
delCard
=
new
DelCommand
(
this
);
this
.
copyCard
=
new
CopyCommand
(
this
);
}
#
region
添加
//添加
public
class
AddCommand
:
IBackableCommand
{
private
string
undoSQL
;
public
class
AddCommand
:
IBackableCommand
{
private
string
undoSQL
;
readonly
IDataForm
dataform
;
public
AddCommand
(
CardEdit
cardedit
)
{
this
.
dataform
=
cardedit
.
dataform
;
}
public
AddCommand
(
CardEdit
cardedit
)
{
this
.
dataform
=
cardedit
.
dataform
;
}
public
bool
Excute
(
params
object
[]
args
)
{
if
(!
this
.
dataform
.
CheckOpen
())
public
bool
Excute
(
params
object
[]
args
)
{
if
(!
this
.
dataform
.
CheckOpen
())
{
return
false
;
}
Card
c
=
this
.
dataform
.
GetCard
();
if
(
c
.
id
<=
0
)
//卡片密码不能小于等于0
{
MyMsg
.
Error
(
LMSG
.
CodeCanNotIsZero
);
return
false
;
}
Card
[]
cards
=
this
.
dataform
.
GetCardList
(
false
);
foreach
(
Card
ckey
in
cards
)
//卡片id存在
{
if
(
c
.
id
==
ckey
.
id
)
{
MyMsg
.
Warning
(
LMSG
.
ItIsExists
);
return
false
;
}
}
if
(
DataBase
.
Command
(
this
.
dataform
.
GetOpenFile
(),
DataBase
.
GetInsertSQL
(
c
,
true
))
>=
2
)
{
MyMsg
.
Show
(
LMSG
.
AddSucceed
);
if
(
c
.
id
<=
0
)
//卡片密码不能小于等于0
{
MyMsg
.
Error
(
LMSG
.
CodeCanNotIsZero
);
return
false
;
}
Card
[]
cards
=
this
.
dataform
.
GetCardList
(
false
);
foreach
(
Card
ckey
in
cards
)
//卡片id存在
{
if
(
c
.
id
==
ckey
.
id
)
{
MyMsg
.
Warning
(
LMSG
.
ItIsExists
);
return
false
;
}
}
if
(
DataBase
.
Command
(
this
.
dataform
.
GetOpenFile
(),
DataBase
.
GetInsertSQL
(
c
,
true
))
>=
2
)
{
MyMsg
.
Show
(
LMSG
.
AddSucceed
);
this
.
undoSQL
=
DataBase
.
GetDeleteSQL
(
c
);
this
.
dataform
.
Search
(
true
);
this
.
dataform
.
SetCard
(
c
);
return
true
;
}
MyMsg
.
Error
(
LMSG
.
AddFail
);
return
false
;
}
public
void
Undo
()
{
DataBase
.
Command
(
this
.
dataform
.
GetOpenFile
(),
this
.
undoSQL
);
}
return
true
;
}
MyMsg
.
Error
(
LMSG
.
AddFail
);
return
false
;
}
public
void
Undo
()
{
DataBase
.
Command
(
this
.
dataform
.
GetOpenFile
(),
this
.
undoSQL
);
}
public
object
Clone
()
{
return
this
.
MemberwiseClone
();
}
}
#
endregion
public
object
Clone
()
{
return
this
.
MemberwiseClone
();
}
}
#
endregion
#
region
修改
//修改
public
class
ModCommand
:
IBackableCommand
{
private
string
undoSQL
;
private
bool
modifiled
=
false
;
private
long
oldid
;
private
long
newid
;
private
bool
delold
;
#
region
修改
//修改
public
class
ModCommand
:
IBackableCommand
{
private
string
undoSQL
;
private
bool
modifiled
=
false
;
private
long
oldid
;
private
long
newid
;
private
bool
delold
;
readonly
IDataForm
dataform
;
public
ModCommand
(
CardEdit
cardedit
)
{
this
.
dataform
=
cardedit
.
dataform
;
}
public
ModCommand
(
CardEdit
cardedit
)
{
this
.
dataform
=
cardedit
.
dataform
;
}
public
bool
Excute
(
params
object
[]
args
)
{
if
(!
this
.
dataform
.
CheckOpen
())
public
bool
Excute
(
params
object
[]
args
)
{
if
(!
this
.
dataform
.
CheckOpen
())
{
return
false
;
}
bool
modfiles
=
(
bool
)
args
[
0
];
Card
c
=
this
.
dataform
.
GetCard
();
Card
oldCard
=
this
.
dataform
.
GetOldCard
();
if
(
c
.
Equals
(
oldCard
))
//没有修改
{
MyMsg
.
Show
(
LMSG
.
ItIsNotChanged
);
return
false
;
}
if
(
c
.
id
<=
0
)
{
MyMsg
.
Error
(
LMSG
.
CodeCanNotIsZero
);
return
false
;
}
string
sql
;
if
(
c
.
id
!=
oldCard
.
id
)
//修改了id
{
sql
=
DataBase
.
GetInsertSQL
(
c
,
false
);
//插入
bool
delold
=
MyMsg
.
Question
(
LMSG
.
IfDeleteCard
);
if
(
delold
)
//是否删除旧卡片
{
if
(
DataBase
.
Command
(
this
.
dataform
.
GetOpenFile
(),
DataBase
.
GetDeleteSQL
(
oldCard
))
<
2
)
{
//删除失败
MyMsg
.
Error
(
LMSG
.
DeleteFail
);
delold
=
false
;
}
else
{
//删除成功,添加还原sql
Card
c
=
this
.
dataform
.
GetCard
();
Card
oldCard
=
this
.
dataform
.
GetOldCard
();
if
(
c
.
Equals
(
oldCard
))
//没有修改
{
MyMsg
.
Show
(
LMSG
.
ItIsNotChanged
);
return
false
;
}
if
(
c
.
id
<=
0
)
{
MyMsg
.
Error
(
LMSG
.
CodeCanNotIsZero
);
return
false
;
}
string
sql
;
if
(
c
.
id
!=
oldCard
.
id
)
//修改了id
{
sql
=
DataBase
.
GetInsertSQL
(
c
,
false
);
//插入
bool
delold
=
MyMsg
.
Question
(
LMSG
.
IfDeleteCard
);
if
(
delold
)
//是否删除旧卡片
{
if
(
DataBase
.
Command
(
this
.
dataform
.
GetOpenFile
(),
DataBase
.
GetDeleteSQL
(
oldCard
))
<
2
)
{
//删除失败
MyMsg
.
Error
(
LMSG
.
DeleteFail
);
delold
=
false
;
}
else
{
//删除成功,添加还原sql
this
.
undoSQL
=
DataBase
.
GetDeleteSQL
(
c
)
+
DataBase
.
GetInsertSQL
(
oldCard
,
false
);
}
}
else
}
}
else
{
this
.
undoSQL
=
DataBase
.
GetDeleteSQL
(
c
);
//还原就是删除
}
//如果删除旧卡片,则把资源修改名字,否则复制资源
if
(
modfiles
)
{
if
(
delold
)
{
if
(
delold
)
{
YGOUtil
.
CardRename
(
c
.
id
,
oldCard
.
id
,
this
.
dataform
.
GetPath
());
}
...
...
@@ -154,37 +152,37 @@ public bool Excute(params object[] args)
}
this
.
modifiled
=
true
;
this
.
oldid
=
oldCard
.
id
;
this
.
newid
=
c
.
id
;
this
.
delold
=
delold
;
}
}
else
{
//更新数据
sql
=
DataBase
.
GetUpdateSQL
(
c
);
this
.
oldid
=
oldCard
.
id
;
this
.
newid
=
c
.
id
;
this
.
delold
=
delold
;
}
}
else
{
//更新数据
sql
=
DataBase
.
GetUpdateSQL
(
c
);
this
.
undoSQL
=
DataBase
.
GetUpdateSQL
(
oldCard
);
}
if
(
DataBase
.
Command
(
this
.
dataform
.
GetOpenFile
(),
sql
)
>
0
)
{
MyMsg
.
Show
(
LMSG
.
ModifySucceed
);
}
if
(
DataBase
.
Command
(
this
.
dataform
.
GetOpenFile
(),
sql
)
>
0
)
{
MyMsg
.
Show
(
LMSG
.
ModifySucceed
);
this
.
dataform
.
Search
(
true
);
this
.
dataform
.
SetCard
(
c
);
return
true
;
}
else
return
true
;
}
else
{
MyMsg
.
Error
(
LMSG
.
ModifyFail
);
}
return
false
;
}
}
public
void
Undo
()
{
DataBase
.
Command
(
this
.
dataform
.
GetOpenFile
(),
this
.
undoSQL
);
if
(
this
.
modifiled
)
{
if
(
this
.
delold
)
public
void
Undo
()
{
DataBase
.
Command
(
this
.
dataform
.
GetOpenFile
(),
this
.
undoSQL
);
if
(
this
.
modifiled
)
{
if
(
this
.
delold
)
{
YGOUtil
.
CardRename
(
this
.
oldid
,
this
.
newid
,
this
.
dataform
.
GetPath
());
}
...
...
@@ -193,112 +191,117 @@ public void Undo()
YGOUtil
.
CardDelete
(
this
.
newid
,
this
.
dataform
.
GetPath
());
}
}
}
}
public
object
Clone
()
{
return
this
.
MemberwiseClone
();
}
}
public
object
Clone
()
{
return
this
.
MemberwiseClone
();
}
}
#
endregion
#
region
删除
//删除
public
class
DelCommand
:
IBackableCommand
{
private
string
undoSQL
;
public
class
DelCommand
:
IBackableCommand
{
private
string
undoSQL
;
readonly
IDataForm
dataform
;
public
DelCommand
(
CardEdit
cardedit
)
{
this
.
dataform
=
cardedit
.
dataform
;
}
public
DelCommand
(
CardEdit
cardedit
)
{
this
.
dataform
=
cardedit
.
dataform
;
}
public
bool
Excute
(
params
object
[]
args
)
{
if
(!
this
.
dataform
.
CheckOpen
())
public
bool
Excute
(
params
object
[]
args
)
{
if
(!
this
.
dataform
.
CheckOpen
())
{
return
false
;
}
bool
deletefiles
=
(
bool
)
args
[
0
];
Card
[]
cards
=
this
.
dataform
.
GetCardList
(
true
);
if
(
cards
==
null
||
cards
.
Length
==
0
)
Card
[]
cards
=
this
.
dataform
.
GetCardList
(
true
);
if
(
cards
==
null
||
cards
.
Length
==
0
)
{
return
false
;
}
string
undo
=
""
;
if
(!
MyMsg
.
Question
(
LMSG
.
IfDeleteCard
))
if
(!
MyMsg
.
Question
(
LMSG
.
IfDeleteCard
))
{
return
false
;
}
List
<
string
>
sql
=
new
List
<
string
>();
foreach
(
Card
c
in
cards
)
{
sql
.
Add
(
DataBase
.
GetDeleteSQL
(
c
));
//删除
undo
+=
DataBase
.
GetInsertSQL
(
c
,
true
);
//删除资源
if
(
deletefiles
)
{
YGOUtil
.
CardDelete
(
c
.
id
,
this
.
dataform
.
GetPath
());
}
}
if
(
DataBase
.
Command
(
this
.
dataform
.
GetOpenFile
(),
sql
.
ToArray
())
>=
(
sql
.
Count
*
2
))
{
MyMsg
.
Show
(
LMSG
.
DeleteSucceed
);
foreach
(
Card
c
in
cards
)
{
sql
.
Add
(
DataBase
.
GetDeleteSQL
(
c
));
//删除
undo
+=
DataBase
.
GetInsertSQL
(
c
,
true
);
//删除资源
if
(
deletefiles
)
{
YGOUtil
.
CardDelete
(
c
.
id
,
this
.
dataform
.
GetPath
());
}
}
if
(
DataBase
.
Command
(
this
.
dataform
.
GetOpenFile
(),
sql
.
ToArray
())
>=
(
sql
.
Count
*
2
))
{
MyMsg
.
Show
(
LMSG
.
DeleteSucceed
);
this
.
dataform
.
Search
(
true
);
this
.
undoSQL
=
undo
;
return
true
;
}
else
{
MyMsg
.
Error
(
LMSG
.
DeleteFail
);
return
true
;
}
else
{
MyMsg
.
Error
(
LMSG
.
DeleteFail
);
this
.
dataform
.
Search
(
true
);
}
return
false
;
}
public
void
Undo
()
{
DataBase
.
Command
(
this
.
dataform
.
GetOpenFile
(),
this
.
undoSQL
);
}
}
return
false
;
}
public
void
Undo
()
{
DataBase
.
Command
(
this
.
dataform
.
GetOpenFile
(),
this
.
undoSQL
);
}
public
object
Clone
()
{
return
this
.
MemberwiseClone
();
}
}
public
object
Clone
()
{
return
this
.
MemberwiseClone
();
}
}
#
endregion
#
region
打开脚本
//打开脚本
public
bool
OpenScript
(
bool
openinthis
,
string
addrequire
)
{
if
(!
this
.
dataform
.
CheckOpen
())
#
region
打开脚本
//打开脚本
public
bool
OpenScript
(
bool
openinthis
,
string
addrequire
)
{
if
(!
this
.
dataform
.
CheckOpen
())
{
return
false
;
}
Card
c
=
this
.
dataform
.
GetCard
();
long
id
=
c
.
id
;
string
lua
;
if
(
c
.
id
>
0
)
{
lua
=
this
.
dataform
.
GetPath
().
GetScript
(
id
);
}
else
if
(
addrequire
.
Length
>
0
)
{
lua
=
this
.
dataform
.
GetPath
().
GetModuleScript
(
addrequire
);
}
else
{
return
false
;
}
if
(!
File
.
Exists
(
lua
))
{
MyPath
.
CreateDirByFile
(
lua
);
if
(
MyMsg
.
Question
(
LMSG
.
IfCreateScript
))
//是否创建脚本
{
using
(
FileStream
fs
=
new
FileStream
(
lua
,
FileMode
.
OpenOrCreate
,
FileAccess
.
Write
))
{
StreamWriter
sw
=
new
StreamWriter
(
fs
,
new
UTF8Encoding
(
false
));
long
id
=
c
.
id
;
string
lua
;
if
(
c
.
id
>
0
)
{
lua
=
this
.
dataform
.
GetPath
().
GetScript
(
id
);
}
else
if
(
addrequire
.
Length
>
0
)
{
lua
=
this
.
dataform
.
GetPath
().
GetModuleScript
(
addrequire
);
}
else
{
return
false
;
}
if
(!
File
.
Exists
(
lua
))
{
MyPath
.
CreateDirByFile
(
lua
);
if
(
MyMsg
.
Question
(
LMSG
.
IfCreateScript
))
//是否创建脚本
{
using
(
FileStream
fs
=
new
FileStream
(
lua
,
FileMode
.
OpenOrCreate
,
FileAccess
.
Write
))
{
StreamWriter
sw
=
new
StreamWriter
(
fs
,
new
UTF8Encoding
(
false
));
if
(
string
.
IsNullOrEmpty
(
addrequire
))
{
// OCG script
...
...
@@ -322,14 +325,14 @@ public bool OpenScript(bool openinthis, string addrequire)
{ //module script
sw.WriteLine("--Module script \"" + addrequire + "\"");
}*/
sw
.
Close
();
fs
.
Close
();
}
}
}
if
(
File
.
Exists
(
lua
))
//如果存在,则打开文件
{
if
(
openinthis
)
//是否用本程序打开
sw
.
Close
();
fs
.
Close
();
}
}
}
if
(
File
.
Exists
(
lua
))
//如果存在,则打开文件
{
if
(
openinthis
)
//是否用本程序打开
{
MyConfig
.
OpenFileInThis
(
lua
);
}
...
...
@@ -339,80 +342,80 @@ public bool OpenScript(bool openinthis, string addrequire)
}
return
true
;
}
return
false
;
}
#
endregion
}
return
false
;
}
#
endregion
#
region
复制卡片
public
class
CopyCommand
:
IBackableCommand
{
bool
copied
=
false
;
Card
[]
newCards
;
bool
replace
;
Card
[]
oldCards
;
#
region
复制卡片
public
class
CopyCommand
:
IBackableCommand
{
bool
copied
=
false
;
Card
[]
newCards
;
bool
replace
;
Card
[]
oldCards
;
readonly
CardEdit
cardedit
;
readonly
IDataForm
dataform
;
public
CopyCommand
(
CardEdit
cardedit
)
{
this
.
cardedit
=
cardedit
;
this
.
dataform
=
cardedit
.
dataform
;
}
public
CopyCommand
(
CardEdit
cardedit
)
{
this
.
cardedit
=
cardedit
;
this
.
dataform
=
cardedit
.
dataform
;
}
public
bool
Excute
(
params
object
[]
args
)
{
if
(!
this
.
dataform
.
CheckOpen
())
public
bool
Excute
(
params
object
[]
args
)
{
if
(!
this
.
dataform
.
CheckOpen
())
{
return
false
;
}
Card
[]
cards
=
(
Card
[])
args
[
0
];
if
(
cards
==
null
||
cards
.
Length
==
0
)
if
(
cards
==
null
||
cards
.
Length
==
0
)
{
return
false
;
}
bool
replace
=
false
;
Card
[]
oldcards
=
DataBase
.
Read
(
this
.
dataform
.
GetOpenFile
(),
true
,
""
);
if
(
oldcards
!=
null
&&
oldcards
.
Length
!=
0
)
{
int
i
=
0
;
foreach
(
Card
oc
in
oldcards
)
{
foreach
(
Card
c
in
cards
)
{
if
(
c
.
id
==
oc
.
id
)
{
i
+=
1
;
if
(
i
==
1
)
{
replace
=
MyMsg
.
Question
(
LMSG
.
IfReplaceExistingCard
);
break
;
}
}
}
if
(
i
>
0
)
Card
[]
oldcards
=
DataBase
.
Read
(
this
.
dataform
.
GetOpenFile
(),
true
,
""
);
if
(
oldcards
!=
null
&&
oldcards
.
Length
!=
0
)
{
int
i
=
0
;
foreach
(
Card
oc
in
oldcards
)
{
foreach
(
Card
c
in
cards
)
{
if
(
c
.
id
==
oc
.
id
)
{
i
+=
1
;
if
(
i
==
1
)
{
replace
=
MyMsg
.
Question
(
LMSG
.
IfReplaceExistingCard
);
break
;
}
}
}
if
(
i
>
0
)
{
break
;
}
}
}
DataBase
.
CopyDB
(
this
.
dataform
.
GetOpenFile
(),
!
replace
,
cards
);
this
.
copied
=
true
;
this
.
newCards
=
cards
;
this
.
replace
=
replace
;
this
.
oldCards
=
oldcards
;
return
true
;
}
public
void
Undo
()
{
DataBase
.
DeleteDB
(
this
.
dataform
.
GetOpenFile
(),
this
.
newCards
);
DataBase
.
CopyDB
(
this
.
dataform
.
GetOpenFile
(),
!
this
.
replace
,
this
.
oldCards
);
}
}
DataBase
.
CopyDB
(
this
.
dataform
.
GetOpenFile
(),
!
replace
,
cards
);
this
.
copied
=
true
;
this
.
newCards
=
cards
;
this
.
replace
=
replace
;
this
.
oldCards
=
oldcards
;
return
true
;
}
public
void
Undo
()
{
DataBase
.
DeleteDB
(
this
.
dataform
.
GetOpenFile
(),
this
.
newCards
);
DataBase
.
CopyDB
(
this
.
dataform
.
GetOpenFile
(),
!
this
.
replace
,
this
.
oldCards
);
}
public
object
Clone
()
{
public
object
Clone
()
{
CopyCommand
replica
=
new
CopyCommand
(
this
.
cardedit
)
{
copied
=
this
.
copied
,
...
...
@@ -425,8 +428,8 @@ public object Clone()
}
return
replica
;
}
}
#
endregion
}
}
}
#
endregion
}
}
DataEditorX/Core/CommandManager.cs
View file @
44764797
...
...
@@ -3,96 +3,96 @@
namespace
DataEditorX.Core
{
public
delegate
void
StatusBool
(
bool
val
);
public
interface
ICommand
:
ICloneable
{
bool
Excute
(
params
object
[]
args
);
}
public
interface
IBackableCommand
:
ICommand
{
void
Undo
();
}
public
interface
ICommandManager
{
void
ExcuteCommand
(
ICommand
command
,
params
object
[]
args
);
void
Undo
();
void
ReverseUndo
();
//反撤销
event
StatusBool
UndoStateChanged
;
}
public
class
CommandManager
:
ICommandManager
{
private
readonly
Stack
<
ICommand
>
undoStack
=
new
Stack
<
ICommand
>();
private
readonly
Stack
<
ICommand
>
reverseStack
=
new
Stack
<
ICommand
>();
public
event
StatusBool
UndoStateChanged
;
public
CommandManager
()
{
UndoStateChanged
+=
new
StatusBool
(
this
.
CommandManager_UndoStateChanged
);
UndoStateChanged
+=
new
StatusBool
(
this
.
CommandManager_ReverseUndoStateChanged
);
}
private
void
CommandManager_UndoStateChanged
(
bool
val
)
{
}
private
void
CommandManager_ReverseUndoStateChanged
(
bool
val
)
{
}
#
region
ICommandManager
成员
public
void
ExcuteCommand
(
ICommand
command
,
params
object
[]
args
)
{
if
(!
command
.
Excute
(
args
))
public
delegate
void
StatusBool
(
bool
val
);
public
interface
ICommand
:
ICloneable
{
bool
Excute
(
params
object
[]
args
);
}
public
interface
IBackableCommand
:
ICommand
{
void
Undo
();
}
public
interface
ICommandManager
{
void
ExcuteCommand
(
ICommand
command
,
params
object
[]
args
);
void
Undo
();
void
ReverseUndo
();
//反撤销
event
StatusBool
UndoStateChanged
;
}
public
class
CommandManager
:
ICommandManager
{
private
readonly
Stack
<
ICommand
>
undoStack
=
new
Stack
<
ICommand
>();
private
readonly
Stack
<
ICommand
>
reverseStack
=
new
Stack
<
ICommand
>();
public
event
StatusBool
UndoStateChanged
;
public
CommandManager
()
{
UndoStateChanged
+=
new
StatusBool
(
this
.
CommandManager_UndoStateChanged
);
UndoStateChanged
+=
new
StatusBool
(
this
.
CommandManager_ReverseUndoStateChanged
);
}
private
void
CommandManager_UndoStateChanged
(
bool
val
)
{
}
private
void
CommandManager_ReverseUndoStateChanged
(
bool
val
)
{
}
#
region
ICommandManager
成员
public
void
ExcuteCommand
(
ICommand
command
,
params
object
[]
args
)
{
if
(!
command
.
Excute
(
args
))
{
return
;
}
this
.
reverseStack
.
Clear
();
if
(
command
is
IBackableCommand
)
{
if
(
command
is
IBackableCommand
)
{
this
.
undoStack
.
Push
((
ICommand
)
command
.
Clone
());
}
else
{
}
else
{
this
.
undoStack
.
Clear
();
}
}
UndoStateChanged
(
this
.
undoStack
.
Count
>
0
);
}
UndoStateChanged
(
this
.
undoStack
.
Count
>
0
);
}
public
void
Undo
()
{
IBackableCommand
command
=
(
IBackableCommand
)
this
.
undoStack
.
Pop
();
if
(
command
==
null
)
{
return
;
}
public
void
Undo
()
{
IBackableCommand
command
=
(
IBackableCommand
)
this
.
undoStack
.
Pop
();
if
(
command
==
null
)
{
return
;
}
command
.
Undo
();
command
.
Undo
();
this
.
reverseStack
.
Push
((
ICommand
)
command
.
Clone
());
UndoStateChanged
(
this
.
undoStack
.
Count
>
0
);
//UndoStateChanged(reverseStack.Count > 0);
}
UndoStateChanged
(
this
.
undoStack
.
Count
>
0
);
//UndoStateChanged(reverseStack.Count > 0);
}
public
void
ReverseUndo
()
{
IBackableCommand
command
=
(
IBackableCommand
)
this
.
reverseStack
.
Pop
();
if
(
command
==
null
)
{
return
;
}
public
void
ReverseUndo
()
{
IBackableCommand
command
=
(
IBackableCommand
)
this
.
reverseStack
.
Pop
();
if
(
command
==
null
)
{
return
;
}
command
.
Excute
();
command
.
Excute
();
this
.
undoStack
.
Push
((
ICommand
)
command
.
Clone
());
UndoStateChanged
(
this
.
undoStack
.
Count
>
0
);
}
#
endregion
}
UndoStateChanged
(
this
.
undoStack
.
Count
>
0
);
}
#
endregion
}
}
DataEditorX/Core/DataBase.cs
View file @
44764797
...
...
@@ -6,41 +6,41 @@
*
*/
using
System
;
using
System.Data.SQLite
;
using
System.Collections.Generic
;
using
System.Data.SQLite
;
using
System.IO
;
using
System.Text
;
namespace
DataEditorX.Core
{
/// <summary>
/// SQLite 操作
/// </summary>
public
static
class
DataBase
{
#
region
默认
static
readonly
string
_defaultSQL
;
static
readonly
string
_defaultTableSQL
;
static
DataBase
()
{
_defaultSQL
=
"SELECT datas.*,texts.* FROM datas,texts WHERE datas.id=texts.id "
;
StringBuilder
st
=
new
StringBuilder
();
st
.
Append
(
@"CREATE TABLE texts(id integer primary key,name text,desc text"
);
for
(
int
i
=
1
;
i
<=
16
;
i
++
)
{
st
.
Append
(
",str"
);
st
.
Append
(
i
.
ToString
());
st
.
Append
(
" text"
);
}
st
.
Append
(
");"
);
st
.
Append
(
@"CREATE TABLE datas("
);
st
.
Append
(
"id integer primary key,ot integer,alias integer,"
);
st
.
Append
(
"setcode integer,type integer,atk integer,def integer,"
);
st
.
Append
(
"level integer,race integer,attribute integer,category integer) "
);
_defaultTableSQL
=
st
.
ToString
();
st
.
Remove
(
0
,
st
.
Length
);
/// <summary>
/// SQLite 操作
/// </summary>
public
static
class
DataBase
{
#
region
默认
static
readonly
string
_defaultSQL
;
static
readonly
string
_defaultTableSQL
;
static
DataBase
()
{
_defaultSQL
=
"SELECT datas.*,texts.* FROM datas,texts WHERE datas.id=texts.id "
;
StringBuilder
st
=
new
StringBuilder
();
st
.
Append
(
@"CREATE TABLE texts(id integer primary key,name text,desc text"
);
for
(
int
i
=
1
;
i
<=
16
;
i
++
)
{
st
.
Append
(
",str"
);
st
.
Append
(
i
.
ToString
());
st
.
Append
(
" text"
);
}
st
.
Append
(
");"
);
st
.
Append
(
@"CREATE TABLE datas("
);
st
.
Append
(
"id integer primary key,ot integer,alias integer,"
);
st
.
Append
(
"setcode integer,type integer,atk integer,def integer,"
);
st
.
Append
(
"level integer,race integer,attribute integer,category integer) "
);
_defaultTableSQL
=
st
.
ToString
();
st
.
Remove
(
0
,
st
.
Length
);
}
#
endregion
...
...
@@ -50,84 +50,85 @@ static DataBase()
/// </summary>
/// <param name="Db">新数据库路径</param>
public
static
bool
Create
(
string
Db
)
{
if
(
File
.
Exists
(
Db
)
)
{
if
(
File
.
Exists
(
Db
)
)
{
File
.
Delete
(
Db
);
}
try
{
SQLiteConnection
.
CreateFile
(
Db
);
Command
(
Db
,
_defaultTableSQL
);
}
catch
{
return
false
;
}
return
true
;
}
public
static
bool
CheckTable
(
string
db
)
{
try
{
Command
(
db
,
_defaultTableSQL
);
}
catch
{
return
false
;
}
return
true
;
}
#
endregion
#
region
执行
sql
语句
/// <summary>
/// 执行sql语句
/// </summary>
/// <param name="DB">数据库</param>
/// <param name="SQLs">sql语句</param>
/// <returns>返回影响行数</returns>
public
static
int
Command
(
string
DB
,
params
string
[]
SQLs
)
{
int
result
=
0
;
if
(
File
.
Exists
(
DB
)
&&
SQLs
!=
null
)
{
using
(
SQLiteConnection
con
=
new
SQLiteConnection
(
@"Data Source="
+
DB
)
)
{
con
.
Open
();
using
(
SQLiteTransaction
trans
=
con
.
BeginTransaction
()
)
{
try
{
using
(
SQLiteCommand
cmd
=
new
SQLiteCommand
(
con
)
)
{
foreach
(
string
SQLstr
in
SQLs
)
{
cmd
.
CommandText
=
SQLstr
;
result
+=
cmd
.
ExecuteNonQuery
();
}
}
}
catch
{
trans
.
Rollback
();
//出错,回滚
result
=
-
1
;
}
finally
{
trans
.
Commit
();
}
}
con
.
Close
();
}
}
return
result
;
}
#
endregion
#
region
根据
SQL
读取
static
Card
ReadCard
(
SQLiteDataReader
reader
,
bool
reNewLine
)
{
SQLiteConnection
.
CreateFile
(
Db
);
Command
(
Db
,
_defaultTableSQL
);
}
catch
{
return
false
;
}
return
true
;
}
public
static
bool
CheckTable
(
string
db
)
{
try
{
Command
(
db
,
_defaultTableSQL
);
}
catch
{
return
false
;
}
return
true
;
}
#
endregion
#
region
执行
sql
语句
/// <summary>
/// 执行sql语句
/// </summary>
/// <param name="DB">数据库</param>
/// <param name="SQLs">sql语句</param>
/// <returns>返回影响行数</returns>
public
static
int
Command
(
string
DB
,
params
string
[]
SQLs
)
{
int
result
=
0
;
if
(
File
.
Exists
(
DB
)
&&
SQLs
!=
null
)
{
using
(
SQLiteConnection
con
=
new
SQLiteConnection
(
@"Data Source="
+
DB
))
{
con
.
Open
();
using
(
SQLiteTransaction
trans
=
con
.
BeginTransaction
())
{
try
{
using
(
SQLiteCommand
cmd
=
new
SQLiteCommand
(
con
))
{
foreach
(
string
SQLstr
in
SQLs
)
{
cmd
.
CommandText
=
SQLstr
;
result
+=
cmd
.
ExecuteNonQuery
();
}
}
}
catch
{
trans
.
Rollback
();
//出错,回滚
result
=
-
1
;
}
finally
{
trans
.
Commit
();
}
}
con
.
Close
();
}
}
return
result
;
}
#
endregion
#
region
根据
SQL
读取
static
Card
ReadCard
(
SQLiteDataReader
reader
,
bool
reNewLine
)
{
Card
c
=
new
Card
(
0
)
{
id
=
reader
.
GetInt64
(
reader
.
GetOrdinal
(
"id"
)),
...
...
@@ -147,45 +148,45 @@ static Card ReadCard(SQLiteDataReader reader,bool reNewLine)
};
if
(
reNewLine
)
{
c
.
desc
=
Retext
(
c
.
desc
);
c
.
desc
=
Retext
(
c
.
desc
);
}
for
(
int
i
=
0
;
i
<
0x10
;
i
++
)
{
for
(
int
i
=
0
;
i
<
0x10
;
i
++
)
{
string
temp
=
reader
.
GetString
(
reader
.
GetOrdinal
(
"str"
+
(
i
+
1
).
ToString
()));
c
.
Str
[
i
]=
temp
??
""
;
}
return
c
;
}
static
string
Retext
(
string
text
)
{
StringBuilder
sr
=
new
StringBuilder
(
text
);
sr
.
Replace
(
"\r\n"
,
"\n"
);
sr
.
Replace
(
"\n"
,
Environment
.
NewLine
);
//换为当前系统的换行符
text
=
sr
.
ToString
();
sr
.
Remove
(
0
,
sr
.
Length
);
return
text
;
}
public
static
Card
[]
Read
(
string
DB
,
bool
reNewLine
,
params
long
[]
ids
)
{
List
<
string
>
idlist
=
new
List
<
string
>();
foreach
(
long
id
in
ids
)
{
idlist
.
Add
(
id
.
ToString
());
}
return
Read
(
DB
,
reNewLine
,
idlist
.
ToArray
());
}
/// <summary>
/// 根据密码集合,读取数据
/// </summary>
/// <param name="DB">数据库</param>
/// <param name="reNewLine">调整换行符</param>
/// <param name="SQLs">SQL/密码语句集合集合</param>
public
static
Card
[]
Read
(
string
DB
,
bool
reNewLine
,
params
string
[]
SQLs
)
{
List
<
Card
>
list
=
new
List
<
Card
>();
List
<
long
>
idlist
=
new
List
<
long
>();
c
.
Str
[
i
]
=
temp
??
""
;
}
return
c
;
}
static
string
Retext
(
string
text
)
{
StringBuilder
sr
=
new
StringBuilder
(
text
);
sr
.
Replace
(
"\r\n"
,
"\n"
);
sr
.
Replace
(
"\n"
,
Environment
.
NewLine
);
//换为当前系统的换行符
text
=
sr
.
ToString
();
sr
.
Remove
(
0
,
sr
.
Length
);
return
text
;
}
public
static
Card
[]
Read
(
string
DB
,
bool
reNewLine
,
params
long
[]
ids
)
{
List
<
string
>
idlist
=
new
List
<
string
>();
foreach
(
long
id
in
ids
)
{
idlist
.
Add
(
id
.
ToString
());
}
return
Read
(
DB
,
reNewLine
,
idlist
.
ToArray
());
}
/// <summary>
/// 根据密码集合,读取数据
/// </summary>
/// <param name="DB">数据库</param>
/// <param name="reNewLine">调整换行符</param>
/// <param name="SQLs">SQL/密码语句集合集合</param>
public
static
Card
[]
Read
(
string
DB
,
bool
reNewLine
,
params
string
[]
SQLs
)
{
List
<
Card
>
list
=
new
List
<
Card
>();
List
<
long
>
idlist
=
new
List
<
long
>();
if
(
File
.
Exists
(
DB
)
&&
SQLs
!=
null
)
{
using
(
SQLiteConnection
sqliteconn
=
new
SQLiteConnection
(
@"Data Source="
+
DB
))
...
...
@@ -242,145 +243,147 @@ public static Card[] Read(string DB,bool reNewLine, params string[] SQLs)
sqliteconn
.
Close
();
}
}
if
(
list
.
Count
==
0
)
if
(
list
.
Count
==
0
)
{
return
null
;
}
return
list
.
ToArray
();
}
#
endregion
#
region
复制数据库
/// <summary>
/// 复制数据库
/// </summary>
/// <param name="DB">复制到的数据库</param>
/// <param name="cards">卡片集合</param>
/// <param name="ignore">是否忽略存在</param>
/// <returns>更新数x2</returns>
public
static
int
CopyDB
(
string
DB
,
bool
ignore
,
params
Card
[]
cards
)
{
int
result
=
0
;
if
(
File
.
Exists
(
DB
)
&&
cards
!=
null
)
{
using
(
SQLiteConnection
con
=
new
SQLiteConnection
(
@"Data Source="
+
DB
)
)
{
con
.
Open
();
using
(
SQLiteTransaction
trans
=
con
.
BeginTransaction
()
)
{
using
(
SQLiteCommand
cmd
=
new
SQLiteCommand
(
con
)
)
{
foreach
(
Card
c
in
cards
)
{
cmd
.
CommandText
=
GetInsertSQL
(
c
,
ignore
);
result
+=
cmd
.
ExecuteNonQuery
();
}
}
trans
.
Commit
();
}
con
.
Close
();
}
}
return
result
;
}
#
endregion
#
region
删除记录
public
static
int
DeleteDB
(
string
DB
,
params
Card
[]
cards
)
{
int
result
=
0
;
if
(
File
.
Exists
(
DB
)
&&
cards
!=
null
)
{
using
(
SQLiteConnection
con
=
new
SQLiteConnection
(
@"Data Source="
+
DB
))
{
con
.
Open
();
using
(
SQLiteTransaction
trans
=
con
.
BeginTransaction
())
{
using
(
SQLiteCommand
cmd
=
new
SQLiteCommand
(
con
))
{
foreach
(
Card
c
in
cards
)
{
cmd
.
CommandText
=
GetDeleteSQL
(
c
);
result
+=
cmd
.
ExecuteNonQuery
();
}
}
trans
.
Commit
();
}
con
.
Close
();
}
}
return
result
;
}
#
endregion
#
region
压缩数据库
public
static
void
Compression
(
string
db
)
{
if
(
File
.
Exists
(
db
))
{
using
(
SQLiteConnection
con
=
new
SQLiteConnection
(
@"Data Source="
+
db
)
)
{
con
.
Open
();
using
(
SQLiteCommand
cmd
=
new
SQLiteCommand
(
con
)
)
{
cmd
.
CommandText
=
"vacuum"
;
cmd
.
ExecuteNonQuery
();
}
con
.
Close
();
}
}
}
#
endregion
#
region
SQL
语句
#
region
查询
static
string
toInt
(
long
l
)
{
unchecked
{
return
((
int
)
l
).
ToString
();
}
}
public
static
string
GetSelectSQL
(
Card
c
)
{
StringBuilder
sb
=
new
StringBuilder
();
sb
.
Append
(
"SELECT datas.*,texts.* FROM datas,texts WHERE datas.id=texts.id "
);
if
(
c
==
null
)
}
#
endregion
#
region
复制数据库
/// <summary>
/// 复制数据库
/// </summary>
/// <param name="DB">复制到的数据库</param>
/// <param name="cards">卡片集合</param>
/// <param name="ignore">是否忽略存在</param>
/// <returns>更新数x2</returns>
public
static
int
CopyDB
(
string
DB
,
bool
ignore
,
params
Card
[]
cards
)
{
int
result
=
0
;
if
(
File
.
Exists
(
DB
)
&&
cards
!=
null
)
{
using
(
SQLiteConnection
con
=
new
SQLiteConnection
(
@"Data Source="
+
DB
))
{
con
.
Open
();
using
(
SQLiteTransaction
trans
=
con
.
BeginTransaction
())
{
using
(
SQLiteCommand
cmd
=
new
SQLiteCommand
(
con
))
{
foreach
(
Card
c
in
cards
)
{
cmd
.
CommandText
=
GetInsertSQL
(
c
,
ignore
);
result
+=
cmd
.
ExecuteNonQuery
();
}
}
trans
.
Commit
();
}
con
.
Close
();
}
}
return
result
;
}
#
endregion
#
region
删除记录
public
static
int
DeleteDB
(
string
DB
,
params
Card
[]
cards
)
{
int
result
=
0
;
if
(
File
.
Exists
(
DB
)
&&
cards
!=
null
)
{
using
(
SQLiteConnection
con
=
new
SQLiteConnection
(
@"Data Source="
+
DB
))
{
con
.
Open
();
using
(
SQLiteTransaction
trans
=
con
.
BeginTransaction
())
{
using
(
SQLiteCommand
cmd
=
new
SQLiteCommand
(
con
))
{
foreach
(
Card
c
in
cards
)
{
cmd
.
CommandText
=
GetDeleteSQL
(
c
);
result
+=
cmd
.
ExecuteNonQuery
();
}
}
trans
.
Commit
();
}
con
.
Close
();
}
}
return
result
;
}
#
endregion
#
region
压缩数据库
public
static
void
Compression
(
string
db
)
{
if
(
File
.
Exists
(
db
))
{
using
(
SQLiteConnection
con
=
new
SQLiteConnection
(
@"Data Source="
+
db
))
{
con
.
Open
();
using
(
SQLiteCommand
cmd
=
new
SQLiteCommand
(
con
))
{
cmd
.
CommandText
=
"vacuum"
;
cmd
.
ExecuteNonQuery
();
}
con
.
Close
();
}
}
}
#
endregion
#
region
SQL
语句
#
region
查询
static
string
toInt
(
long
l
)
{
unchecked
{
return
((
int
)
l
).
ToString
();
}
}
public
static
string
GetSelectSQL
(
Card
c
)
{
StringBuilder
sb
=
new
StringBuilder
();
sb
.
Append
(
"SELECT datas.*,texts.* FROM datas,texts WHERE datas.id=texts.id "
);
if
(
c
==
null
)
{
return
sb
.
ToString
();
}
if
(!
string
.
IsNullOrEmpty
(
c
.
name
)){
if
(
c
.
name
.
IndexOf
(
"%%"
)>=
0
)
if
(!
string
.
IsNullOrEmpty
(
c
.
name
))
{
if
(
c
.
name
.
IndexOf
(
"%%"
)
>=
0
)
{
c
.
name
=
c
.
name
.
Replace
(
"%%"
,
"%"
);
c
.
name
=
c
.
name
.
Replace
(
"%%"
,
"%"
);
}
else
{
c
.
name
=
"%"
+
c
.
name
.
Replace
(
"%"
,
"/%"
).
Replace
(
"_"
,
"/_"
)+
"%"
;
c
.
name
=
"%"
+
c
.
name
.
Replace
(
"%"
,
"/%"
).
Replace
(
"_"
,
"/_"
)
+
"%"
;
}
sb
.
Append
(
" and texts.name like '"
+
c
.
name
.
Replace
(
"'"
,
"''"
)+
"' "
);
}
if
(!
string
.
IsNullOrEmpty
(
c
.
desc
))
sb
.
Append
(
" and texts.name like '"
+
c
.
name
.
Replace
(
"'"
,
"''"
)
+
"' "
);
}
if
(!
string
.
IsNullOrEmpty
(
c
.
desc
))
{
sb
.
Append
(
" and texts.desc like '%"
+
c
.
desc
.
Replace
(
"'"
,
"''"
)
+
"%' "
);
sb
.
Append
(
" and texts.desc like '%"
+
c
.
desc
.
Replace
(
"'"
,
"''"
)
+
"%' "
);
}
if
(
c
.
ot
>
0
)
if
(
c
.
ot
>
0
)
{
sb
.
Append
(
" and datas.ot = "
+
c
.
ot
.
ToString
());
sb
.
Append
(
" and datas.ot = "
+
c
.
ot
.
ToString
());
}
if
(
c
.
attribute
>
0
)
if
(
c
.
attribute
>
0
)
{
sb
.
Append
(
" and datas.attribute = "
+
c
.
attribute
.
ToString
());
sb
.
Append
(
" and datas.attribute = "
+
c
.
attribute
.
ToString
());
}
if
((
c
.
level
&
0xff
)
>
0
)
{
sb
.
Append
(
" and (datas.level & 255) = "
+
toInt
(
c
.
level
&
0xff
));
sb
.
Append
(
" and (datas.level & 255) = "
+
toInt
(
c
.
level
&
0xff
));
}
if
((
c
.
level
&
0xff000000
)
>
0
)
...
...
@@ -393,28 +396,28 @@ public static string GetSelectSQL(Card c)
sb
.
Append
(
" and (datas.level & 16711680) = "
+
toInt
(
c
.
level
&
0xff0000
));
}
if
(
c
.
race
>
0
)
if
(
c
.
race
>
0
)
{
sb
.
Append
(
" and datas.race = "
+
toInt
(
c
.
race
));
sb
.
Append
(
" and datas.race = "
+
toInt
(
c
.
race
));
}
if
(
c
.
type
>
0
)
if
(
c
.
type
>
0
)
{
sb
.
Append
(
" and datas.type & "
+
toInt
(
c
.
type
)+
" = "
+
toInt
(
c
.
type
));
sb
.
Append
(
" and datas.type & "
+
toInt
(
c
.
type
)
+
" = "
+
toInt
(
c
.
type
));
}
if
(
c
.
category
>
0
)
if
(
c
.
category
>
0
)
{
sb
.
Append
(
" and datas.category & "
+
toInt
(
c
.
category
)+
" = "
+
toInt
(
c
.
category
));
sb
.
Append
(
" and datas.category & "
+
toInt
(
c
.
category
)
+
" = "
+
toInt
(
c
.
category
));
}
if
(
c
.
atk
==
-
1
)
if
(
c
.
atk
==
-
1
)
{
sb
.
Append
(
" and datas.type & 1 = 1 and datas.atk = 0"
);
}
else
if
(
c
.
atk
<
0
||
c
.
atk
>
0
)
else
if
(
c
.
atk
<
0
||
c
.
atk
>
0
)
{
sb
.
Append
(
" and datas.atk = "
+
c
.
atk
.
ToString
());
sb
.
Append
(
" and datas.atk = "
+
c
.
atk
.
ToString
());
}
if
(
c
.
IsType
(
Info
.
CardType
.
TYPE_LINK
))
...
...
@@ -432,36 +435,36 @@ public static string GetSelectSQL(Card c)
sb
.
Append
(
" and datas.def = "
+
c
.
def
.
ToString
());
}
}
if
(
c
.
id
>
0
&&
c
.
alias
>
0
)
if
(
c
.
id
>
0
&&
c
.
alias
>
0
)
{
sb
.
Append
(
" and datas.id BETWEEN "
+
c
.
alias
.
ToString
()+
" and "
+
c
.
id
.
ToString
());
sb
.
Append
(
" and datas.id BETWEEN "
+
c
.
alias
.
ToString
()
+
" and "
+
c
.
id
.
ToString
());
}
else
if
(
c
.
id
>
0
)
{
sb
.
Append
(
" and ( datas.id="
+
c
.
id
.
ToString
()+
" or datas.alias="
+
c
.
id
.
ToString
()+
") "
);
}
else
if
(
c
.
alias
>
0
)
else
if
(
c
.
id
>
0
)
{
sb
.
Append
(
" and datas.alias= "
+
c
.
alias
.
ToString
());
sb
.
Append
(
" and ( datas.id="
+
c
.
id
.
ToString
()
+
" or datas.alias="
+
c
.
id
.
ToString
()
+
") "
);
}
else
if
(
c
.
alias
>
0
)
{
sb
.
Append
(
" and datas.alias= "
+
c
.
alias
.
ToString
());
}
return
sb
.
ToString
();
}
#
endregion
#
region
插入
/// <summary>
/// 转换为插入语句
/// </summary>
/// <param name="c">卡片数据</param>
/// <param name="ignore"></param>
/// <returns>SQL语句</returns>
public
static
string
GetInsertSQL
(
Card
c
,
bool
ignore
,
bool
hex
=
false
)
{
StringBuilder
st
=
new
StringBuilder
();
if
(
ignore
)
}
#
endregion
#
region
插入
/// <summary>
/// 转换为插入语句
/// </summary>
/// <param name="c">卡片数据</param>
/// <param name="ignore"></param>
/// <returns>SQL语句</returns>
public
static
string
GetInsertSQL
(
Card
c
,
bool
ignore
,
bool
hex
=
false
)
{
StringBuilder
st
=
new
StringBuilder
();
if
(
ignore
)
{
st
.
Append
(
"INSERT or ignore into datas values("
);
}
...
...
@@ -471,29 +474,35 @@ public static string GetInsertSQL(Card c, bool ignore,bool hex= false)
}
st
.
Append
(
c
.
id
.
ToString
());
st
.
Append
(
","
);
st
.
Append
(
c
.
ot
.
ToString
());
st
.
Append
(
","
);
st
.
Append
(
c
.
alias
.
ToString
());
st
.
Append
(
","
);
if
(
hex
){
st
.
Append
(
"0x"
+
c
.
setcode
.
ToString
(
"x"
));
st
.
Append
(
","
);
st
.
Append
(
"0x"
+
c
.
type
.
ToString
(
"x"
));
st
.
Append
(
","
);
}
else
{
st
.
Append
(
c
.
setcode
.
ToString
());
st
.
Append
(
","
);
st
.
Append
(
c
.
type
.
ToString
());
st
.
Append
(
","
);
}
st
.
Append
(
c
.
atk
.
ToString
());
;
st
.
Append
(
","
);
st
.
Append
(
c
.
def
.
ToString
());
st
.
Append
(
","
);
if
(
hex
){
st
.
Append
(
"0x"
+
c
.
level
.
ToString
(
"x"
));
st
.
Append
(
","
);
st
.
Append
(
"0x"
+
c
.
race
.
ToString
(
"x"
));
st
.
Append
(
","
);
st
.
Append
(
"0x"
+
c
.
attribute
.
ToString
(
"x"
));
st
.
Append
(
","
);
st
.
Append
(
"0x"
+
c
.
category
.
ToString
(
"x"
));
st
.
Append
(
")"
);
}
else
{
st
.
Append
(
c
.
level
.
ToString
());
st
.
Append
(
","
);
st
.
Append
(
c
.
race
.
ToString
());
st
.
Append
(
","
);
st
.
Append
(
c
.
attribute
.
ToString
());
st
.
Append
(
","
);
st
.
Append
(
c
.
category
.
ToString
());
st
.
Append
(
")"
);
}
if
(
ignore
)
st
.
Append
(
c
.
ot
.
ToString
());
st
.
Append
(
","
);
st
.
Append
(
c
.
alias
.
ToString
());
st
.
Append
(
","
);
if
(
hex
)
{
st
.
Append
(
"0x"
+
c
.
setcode
.
ToString
(
"x"
));
st
.
Append
(
","
);
st
.
Append
(
"0x"
+
c
.
type
.
ToString
(
"x"
));
st
.
Append
(
","
);
}
else
{
st
.
Append
(
c
.
setcode
.
ToString
());
st
.
Append
(
","
);
st
.
Append
(
c
.
type
.
ToString
());
st
.
Append
(
","
);
}
st
.
Append
(
c
.
atk
.
ToString
());
;
st
.
Append
(
","
);
st
.
Append
(
c
.
def
.
ToString
());
st
.
Append
(
","
);
if
(
hex
)
{
st
.
Append
(
"0x"
+
c
.
level
.
ToString
(
"x"
));
st
.
Append
(
","
);
st
.
Append
(
"0x"
+
c
.
race
.
ToString
(
"x"
));
st
.
Append
(
","
);
st
.
Append
(
"0x"
+
c
.
attribute
.
ToString
(
"x"
));
st
.
Append
(
","
);
st
.
Append
(
"0x"
+
c
.
category
.
ToString
(
"x"
));
st
.
Append
(
")"
);
}
else
{
st
.
Append
(
c
.
level
.
ToString
());
st
.
Append
(
","
);
st
.
Append
(
c
.
race
.
ToString
());
st
.
Append
(
","
);
st
.
Append
(
c
.
attribute
.
ToString
());
st
.
Append
(
","
);
st
.
Append
(
c
.
category
.
ToString
());
st
.
Append
(
")"
);
}
if
(
ignore
)
{
st
.
Append
(
";\nINSERT or ignore into texts values("
);
}
...
...
@@ -503,97 +512,99 @@ public static string GetInsertSQL(Card c, bool ignore,bool hex= false)
}
st
.
Append
(
c
.
id
.
ToString
());
st
.
Append
(
",'"
);
st
.
Append
(
c
.
name
.
Replace
(
"'"
,
"''"
));
st
.
Append
(
"','"
);
st
.
Append
(
c
.
desc
.
Replace
(
"'"
,
"''"
));
for
(
int
i
=
0
;
i
<
0x10
;
i
++
)
{
st
.
Append
(
"','"
);
st
.
Append
(
c
.
Str
[
i
].
Replace
(
"'"
,
"''"
));
}
st
.
Append
(
"');"
);
string
sql
=
st
.
ToString
();
st
.
Append
(
c
.
name
.
Replace
(
"'"
,
"''"
));
st
.
Append
(
"','"
);
st
.
Append
(
c
.
desc
.
Replace
(
"'"
,
"''"
));
for
(
int
i
=
0
;
i
<
0x10
;
i
++
)
{
st
.
Append
(
"','"
);
st
.
Append
(
c
.
Str
[
i
].
Replace
(
"'"
,
"''"
));
}
st
.
Append
(
"');"
);
string
sql
=
st
.
ToString
();
return
sql
;
}
#
endregion
#
region
更新
/// <summary>
/// 转换为更新语句
/// </summary>
/// <param name="c">卡片数据</param>
/// <returns>SQL语句</returns>
public
static
string
GetUpdateSQL
(
Card
c
)
{
StringBuilder
st
=
new
StringBuilder
();
st
.
Append
(
"update datas set ot="
);
st
.
Append
(
c
.
ot
.
ToString
());
st
.
Append
(
",alias="
);
st
.
Append
(
c
.
alias
.
ToString
());
st
.
Append
(
",setcode="
);
st
.
Append
(
c
.
setcode
.
ToString
());
st
.
Append
(
",type="
);
st
.
Append
(
c
.
type
.
ToString
());
st
.
Append
(
",atk="
);
st
.
Append
(
c
.
atk
.
ToString
());
st
.
Append
(
",def="
);
st
.
Append
(
c
.
def
.
ToString
());
st
.
Append
(
",level="
);
st
.
Append
(
c
.
level
.
ToString
());
st
.
Append
(
",race="
);
st
.
Append
(
c
.
race
.
ToString
());
st
.
Append
(
",attribute="
);
st
.
Append
(
c
.
attribute
.
ToString
());
st
.
Append
(
",category="
);
st
.
Append
(
c
.
category
.
ToString
());
st
.
Append
(
" where id="
);
st
.
Append
(
c
.
id
.
ToString
());
st
.
Append
(
"; update texts set name='"
);
st
.
Append
(
c
.
name
.
Replace
(
"'"
,
"''"
));
st
.
Append
(
"',desc='"
);
st
.
Append
(
c
.
desc
.
Replace
(
"'"
,
"''"
));
st
.
Append
(
"', "
);
for
(
int
i
=
0
;
i
<
0x10
;
i
++
)
{
st
.
Append
(
"str"
);
st
.
Append
((
i
+
1
).
ToString
());
st
.
Append
(
"='"
);
st
.
Append
(
c
.
Str
[
i
].
Replace
(
"'"
,
"''"
));
if
(
i
<
15
)
{
st
.
Append
(
"',"
);
}
}
st
.
Append
(
"' where id="
);
st
.
Append
(
c
.
id
.
ToString
());
st
.
Append
(
";"
);
string
sql
=
st
.
ToString
();
}
#
endregion
#
region
更新
/// <summary>
/// 转换为更新语句
/// </summary>
/// <param name="c">卡片数据</param>
/// <returns>SQL语句</returns>
public
static
string
GetUpdateSQL
(
Card
c
)
{
StringBuilder
st
=
new
StringBuilder
();
st
.
Append
(
"update datas set ot="
);
st
.
Append
(
c
.
ot
.
ToString
());
st
.
Append
(
",alias="
);
st
.
Append
(
c
.
alias
.
ToString
());
st
.
Append
(
",setcode="
);
st
.
Append
(
c
.
setcode
.
ToString
());
st
.
Append
(
",type="
);
st
.
Append
(
c
.
type
.
ToString
());
st
.
Append
(
",atk="
);
st
.
Append
(
c
.
atk
.
ToString
());
st
.
Append
(
",def="
);
st
.
Append
(
c
.
def
.
ToString
());
st
.
Append
(
",level="
);
st
.
Append
(
c
.
level
.
ToString
());
st
.
Append
(
",race="
);
st
.
Append
(
c
.
race
.
ToString
());
st
.
Append
(
",attribute="
);
st
.
Append
(
c
.
attribute
.
ToString
());
st
.
Append
(
",category="
);
st
.
Append
(
c
.
category
.
ToString
());
st
.
Append
(
" where id="
);
st
.
Append
(
c
.
id
.
ToString
());
st
.
Append
(
"; update texts set name='"
);
st
.
Append
(
c
.
name
.
Replace
(
"'"
,
"''"
));
st
.
Append
(
"',desc='"
);
st
.
Append
(
c
.
desc
.
Replace
(
"'"
,
"''"
));
st
.
Append
(
"', "
);
for
(
int
i
=
0
;
i
<
0x10
;
i
++
)
{
st
.
Append
(
"str"
);
st
.
Append
((
i
+
1
).
ToString
());
st
.
Append
(
"='"
);
st
.
Append
(
c
.
Str
[
i
].
Replace
(
"'"
,
"''"
));
if
(
i
<
15
)
{
st
.
Append
(
"',"
);
}
}
st
.
Append
(
"' where id="
);
st
.
Append
(
c
.
id
.
ToString
());
st
.
Append
(
";"
);
string
sql
=
st
.
ToString
();
return
sql
;
}
#
endregion
#
region
删除
/// <summary>
/// 转换删除语句
/// </summary>
/// <param name="c">卡片密码</param>
/// <returns>SQL语句</returns>
public
static
string
GetDeleteSQL
(
Card
c
)
{
string
id
=
c
.
id
.
ToString
();
return
"Delete from datas where id="
+
id
+
";Delete from texts where id="
+
id
+
";"
;
}
#
endregion
#
endregion
public
static
void
ExportSql
(
string
file
,
params
Card
[]
cards
){
using
(
FileStream
fs
=
new
FileStream
(
file
,
FileMode
.
Create
,
FileAccess
.
Write
))
{
StreamWriter
sw
=
new
StreamWriter
(
fs
,
Encoding
.
UTF8
);
foreach
(
Card
c
in
cards
)
{
sw
.
WriteLine
(
GetInsertSQL
(
c
,
false
,
true
));
}
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
())
{
}
#
endregion
#
region
删除
/// <summary>
/// 转换删除语句
/// </summary>
/// <param name="c">卡片密码</param>
/// <returns>SQL语句</returns>
public
static
string
GetDeleteSQL
(
Card
c
)
{
string
id
=
c
.
id
.
ToString
();
return
"Delete from datas where id="
+
id
+
";Delete from texts where id="
+
id
+
";"
;
}
#
endregion
#
endregion
public
static
void
ExportSql
(
string
file
,
params
Card
[]
cards
)
{
using
(
FileStream
fs
=
new
FileStream
(
file
,
FileMode
.
Create
,
FileAccess
.
Write
))
{
StreamWriter
sw
=
new
StreamWriter
(
fs
,
Encoding
.
UTF8
);
foreach
(
Card
c
in
cards
)
{
sw
.
WriteLine
(
GetInsertSQL
(
c
,
false
,
true
));
}
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
)
{
pack_id
=
reader
.
GetString
(
1
),
...
...
@@ -602,13 +613,13 @@ public static string GetDeleteSQL(Card c)
date
=
reader
.
GetString
(
4
)
};
}
reader
.
Close
();
}
}
sqliteconn
.
Close
();
}
}
return
cardpack
;
}
}
reader
.
Close
();
}
}
sqliteconn
.
Close
();
}
}
return
cardpack
;
}
}
}
DataEditorX/Core/Info/CardAttribute.cs
View file @
44764797
...
...
@@ -5,7 +5,6 @@
* 时间: 9:47
*
*/
using
System
;
namespace
DataEditorX.Core.Info
{
...
...
DataEditorX/Core/Info/CardLink.cs
View file @
44764797
...
...
@@ -6,13 +6,12 @@
*
* 要改变这种模板请点击 工具|选项|代码编写|编辑标准头文件
*/
using
System
;
namespace
DataEditorX.Core.Info
{
public
static
class
CardLink
{
/*
public
static
class
CardLink
{
/*
0x1 ↙
0x2 ↓
0x4 ↘
...
...
@@ -21,17 +20,18 @@ public static class CardLink
0x40 ↖
0x80 ↑
0x100 ↗*/
public
const
int
DownLeft
=
0x1
;
public
const
int
Down
=
0x2
;
public
const
int
DownRight
=
0x4
;
public
const
int
Left
=
0x8
;
public
const
int
Right
=
0x20
;
public
const
int
UpLeft
=
0x40
;
public
const
int
Up
=
0x80
;
public
const
int
UpRight
=
0x100
;
public
static
bool
IsLink
(
int
marks
,
int
mark
){
return
(
marks
&
mark
)
==
mark
;
}
}
public
const
int
DownLeft
=
0x1
;
public
const
int
Down
=
0x2
;
public
const
int
DownRight
=
0x4
;
public
const
int
Left
=
0x8
;
public
const
int
Right
=
0x20
;
public
const
int
UpLeft
=
0x40
;
public
const
int
Up
=
0x80
;
public
const
int
UpRight
=
0x100
;
public
static
bool
IsLink
(
int
marks
,
int
mark
)
{
return
(
marks
&
mark
)
==
mark
;
}
}
}
DataEditorX/Core/Info/CardRace.cs
View file @
44764797
...
...
@@ -5,7 +5,6 @@
* 时间: 9:44
*
*/
using
System
;
namespace
DataEditorX.Core.Info
{
...
...
DataEditorX/Core/Info/CardRule.cs
View file @
44764797
namespace
DataEditorX.Core.Info
{
public
enum
CardRule
:
int
public
enum
CardRule
:
int
{
/// <summary>无</summary>
NONE
=
0
,
...
...
DataEditorX/Core/Info/CardType.cs
View file @
44764797
...
...
@@ -5,188 +5,196 @@
* 时间: 9:08
*
*/
using
System
;
using
System.Collections.Generic
;
namespace
DataEditorX.Core.Info
{
/// <summary>
/// 卡片类型
/// </summary>
public
enum
CardType
:
long
{
///<summary>怪兽卡</summary>
TYPE_MONSTER
=
0x1
,
///<summary>魔法卡</summary>
TYPE_SPELL
=
0x2
,
///<summary>陷阱卡</summary>
TYPE_TRAP
=
0x4
,
///<summary>通常</summary>
TYPE_NORMAL
=
0x10
,
///<summary>效果</summary>
TYPE_EFFECT
=
0x20
,
///<summary>融合</summary>
TYPE_FUSION
=
0x40
,
///<summary>仪式</summary>
TYPE_RITUAL
=
0x80
,
///<summary>陷阱怪兽</summary>
TYPE_TRAPMONSTER
=
0x100
,
///<summary>灵魂</summary>
TYPE_SPIRIT
=
0x200
,
///<summary>同盟</summary>
TYPE_UNION
=
0x400
,
///<summary>二重</summary>
TYPE_DUAL
=
0x800
,
///<summary>调整</summary>
TYPE_TUNER
=
0x1000
,
///<summary>同调</summary>
TYPE_SYNCHRO
=
0x2000
,
///<summary>衍生物</summary>
TYPE_TOKEN
=
0x4000
,
///<summary>速攻</summary>
TYPE_QUICKPLAY
=
0x10000
,
///<summary>永续</summary>
TYPE_CONTINUOUS
=
0x20000
,
///<summary>装备</summary>
TYPE_EQUIP
=
0x40000
,
///<summary>场地</summary>
TYPE_FIELD
=
0x80000
,
///<summary>反击</summary>
TYPE_COUNTER
=
0x100000
,
///<summary>反转</summary>
TYPE_FLIP
=
0x200000
,
///<summary>卡通</summary>
TYPE_TOON
=
0x400000
,
///<summary>超量</summary>
TYPE_XYZ
=
0x800000
,
///<summary>灵摆</summary>
TYPE_PENDULUM
=
0x1000000
,
///<summary>特殊召唤</summary>
TYPE_SPSUMMON
=
0x2000000
,
///<summary>连接</summary>
TYPE_LINK
=
0x4000000
,
/// <summary>
/// 卡片类型
/// </summary>
public
enum
CardType
:
long
{
///<summary>怪兽卡</summary>
TYPE_MONSTER
=
0x1
,
///<summary>魔法卡</summary>
TYPE_SPELL
=
0x2
,
///<summary>陷阱卡</summary>
TYPE_TRAP
=
0x4
,
}
public
static
class
CardTypes
{
public
static
readonly
CardType
[]
TYPE1
=
{
CardType
.
TYPE_TOKEN
,
CardType
.
TYPE_LINK
,
CardType
.
TYPE_RITUAL
,
CardType
.
TYPE_FUSION
,
CardType
.
TYPE_XYZ
,
CardType
.
TYPE_SYNCHRO
,
CardType
.
TYPE_PENDULUM
,
CardType
.
TYPE_SPIRIT
,
CardType
.
TYPE_UNION
,
CardType
.
TYPE_DUAL
,
CardType
.
TYPE_FLIP
,
CardType
.
TYPE_TOON
,
};
public
static
readonly
CardType
[]
TYPE1_10
=
{
CardType
.
TYPE_TOKEN
,
CardType
.
TYPE_LINK
,
CardType
.
TYPE_RITUAL
,
CardType
.
TYPE_FUSION
,
CardType
.
TYPE_XYZ
,
CardType
.
TYPE_SYNCHRO
,
CardType
.
TYPE_PENDULUM
,
CardType
.
TYPE_SPIRIT
,
CardType
.
TYPE_UNION
,
CardType
.
TYPE_DUAL
,
CardType
.
TYPE_FLIP
,
CardType
.
TYPE_TOON
,
CardType
.
TYPE_SPSUMMON
,
};
public
static
readonly
CardType
[]
TYPE2
=
{
CardType
.
TYPE_XYZ
,
CardType
.
TYPE_SYNCHRO
,
CardType
.
TYPE_PENDULUM
,
CardType
.
TYPE_SPIRIT
,
CardType
.
TYPE_UNION
,
CardType
.
TYPE_DUAL
,
CardType
.
TYPE_FLIP
,
CardType
.
TYPE_TOON
,
};
public
static
readonly
CardType
[]
TYPE2_10
=
{
CardType
.
TYPE_XYZ
,
CardType
.
TYPE_SYNCHRO
,
CardType
.
TYPE_PENDULUM
,
CardType
.
TYPE_SPIRIT
,
CardType
.
TYPE_UNION
,
CardType
.
TYPE_DUAL
,
CardType
.
TYPE_FLIP
,
CardType
.
TYPE_TOON
,
CardType
.
TYPE_SPSUMMON
,
};
public
static
readonly
CardType
[]
TYPE3
={
CardType
.
TYPE_SYNCHRO
,
CardType
.
TYPE_PENDULUM
,
CardType
.
TYPE_SPIRIT
,
CardType
.
TYPE_UNION
,
CardType
.
TYPE_DUAL
,
CardType
.
TYPE_FLIP
,
CardType
.
TYPE_TOON
,
};
public
static
readonly
CardType
[]
TYPE3_10
={
CardType
.
TYPE_SYNCHRO
,
CardType
.
TYPE_PENDULUM
,
CardType
.
TYPE_SPIRIT
,
CardType
.
TYPE_UNION
,
CardType
.
TYPE_DUAL
,
CardType
.
TYPE_FLIP
,
CardType
.
TYPE_TOON
,
CardType
.
TYPE_SPSUMMON
,
};
public
static
readonly
CardType
[]
TYPE4
={
CardType
.
TYPE_TUNER
,
CardType
.
TYPE_EFFECT
,
///<summary>通常</summary>
TYPE_NORMAL
=
0x10
,
///<summary>效果</summary>
TYPE_EFFECT
=
0x20
,
///<summary>融合</summary>
TYPE_FUSION
=
0x40
,
///<summary>仪式</summary>
TYPE_RITUAL
=
0x80
,
///<summary>陷阱怪兽</summary>
TYPE_TRAPMONSTER
=
0x100
,
///<summary>灵魂</summary>
TYPE_SPIRIT
=
0x200
,
///<summary>同盟</summary>
TYPE_UNION
=
0x400
,
///<summary>二重</summary>
TYPE_DUAL
=
0x800
,
///<summary>调整</summary>
TYPE_TUNER
=
0x1000
,
///<summary>同调</summary>
TYPE_SYNCHRO
=
0x2000
,
///<summary>衍生物</summary>
TYPE_TOKEN
=
0x4000
,
///<summary>速攻</summary>
TYPE_QUICKPLAY
=
0x10000
,
///<summary>永续</summary>
TYPE_CONTINUOUS
=
0x20000
,
///<summary>装备</summary>
TYPE_EQUIP
=
0x40000
,
///<summary>场地</summary>
TYPE_FIELD
=
0x80000
,
///<summary>反击</summary>
TYPE_COUNTER
=
0x100000
,
///<summary>反转</summary>
TYPE_FLIP
=
0x200000
,
///<summary>卡通</summary>
TYPE_TOON
=
0x400000
,
///<summary>超量</summary>
TYPE_XYZ
=
0x800000
,
///<summary>灵摆</summary>
TYPE_PENDULUM
=
0x1000000
,
///<summary>特殊召唤</summary>
TYPE_SPSUMMON
=
0x2000000
,
///<summary>连接</summary>
TYPE_LINK
=
0x4000000
,
}
public
static
class
CardTypes
{
public
static
readonly
CardType
[]
TYPE1
=
{
CardType
.
TYPE_TOKEN
,
CardType
.
TYPE_LINK
,
CardType
.
TYPE_RITUAL
,
CardType
.
TYPE_FUSION
,
CardType
.
TYPE_XYZ
,
CardType
.
TYPE_SYNCHRO
,
CardType
.
TYPE_PENDULUM
,
CardType
.
TYPE_SPIRIT
,
CardType
.
TYPE_UNION
,
CardType
.
TYPE_DUAL
,
CardType
.
TYPE_FLIP
,
CardType
.
TYPE_TOON
,
};
public
static
readonly
CardType
[]
TYPE1_10
=
{
CardType
.
TYPE_TOKEN
,
CardType
.
TYPE_LINK
,
CardType
.
TYPE_RITUAL
,
CardType
.
TYPE_FUSION
,
CardType
.
TYPE_XYZ
,
CardType
.
TYPE_SYNCHRO
,
CardType
.
TYPE_PENDULUM
,
CardType
.
TYPE_SPIRIT
,
CardType
.
TYPE_UNION
,
CardType
.
TYPE_DUAL
,
CardType
.
TYPE_FLIP
,
CardType
.
TYPE_TOON
,
CardType
.
TYPE_SPSUMMON
,
};
public
static
readonly
CardType
[]
TYPE2
=
{
CardType
.
TYPE_XYZ
,
CardType
.
TYPE_SYNCHRO
,
CardType
.
TYPE_PENDULUM
,
CardType
.
TYPE_SPIRIT
,
CardType
.
TYPE_UNION
,
CardType
.
TYPE_DUAL
,
CardType
.
TYPE_FLIP
,
CardType
.
TYPE_TOON
,
};
public
static
readonly
CardType
[]
TYPE2_10
=
{
CardType
.
TYPE_XYZ
,
CardType
.
TYPE_SYNCHRO
,
CardType
.
TYPE_PENDULUM
,
CardType
.
TYPE_SPIRIT
,
CardType
.
TYPE_UNION
,
CardType
.
TYPE_DUAL
,
CardType
.
TYPE_FLIP
,
CardType
.
TYPE_TOON
,
CardType
.
TYPE_SPSUMMON
,
};
public
static
readonly
CardType
[]
TYPE3
={
CardType
.
TYPE_SYNCHRO
,
CardType
.
TYPE_PENDULUM
,
CardType
.
TYPE_SPIRIT
,
CardType
.
TYPE_UNION
,
CardType
.
TYPE_DUAL
,
CardType
.
TYPE_FLIP
,
CardType
.
TYPE_TOON
,
};
public
static
readonly
CardType
[]
TYPE3_10
={
CardType
.
TYPE_SYNCHRO
,
CardType
.
TYPE_PENDULUM
,
CardType
.
TYPE_SPIRIT
,
CardType
.
TYPE_UNION
,
CardType
.
TYPE_DUAL
,
CardType
.
TYPE_FLIP
,
CardType
.
TYPE_TOON
,
CardType
.
TYPE_SPSUMMON
,
};
public
static
readonly
CardType
[]
TYPE4
={
CardType
.
TYPE_TUNER
,
CardType
.
TYPE_EFFECT
,
// CardType.TYPE_NORMAL,
};
public
static
readonly
CardType
[]
TYPE4_10
={
CardType
.
TYPE_TUNER
,
CardType
.
TYPE_EFFECT
,
CardType
.
TYPE_NORMAL
,
};
public
static
CardType
[]
GetMonsterTypes
(
long
type
,
bool
no10
=
false
){
var
list
=
new
List
<
CardType
>(
5
);
var
typeList
=
new
List
<
CardType
[
]>
(
5
);
if
(
no10
){
typeList
.
Add
(
TYPE1_10
);
typeList
.
Add
(
TYPE2_10
);
typeList
.
Add
(
TYPE3_10
);
typeList
.
Add
(
TYPE4_10
);
typeList
.
Add
(
TYPE4_10
);
}
else
{
typeList
.
Add
(
TYPE1
);
typeList
.
Add
(
TYPE2
);
typeList
.
Add
(
TYPE3
);
typeList
.
Add
(
TYPE4
);
typeList
.
Add
(
TYPE4
);
}
int
count
=
typeList
.
Count
;
for
(
int
i
=
0
;
i
<
count
;
i
++){
CardType
[]
types
=
typeList
[
i
];
foreach
(
var
t
in
types
){
if
((
type
&
(
long
)
t
)==(
long
)
t
){
if
(!
list
.
Contains
(
t
)){
list
.
Add
(
t
);
break
;
}
}
}
}
return
list
.
ToArray
();
}
}
public
static
readonly
CardType
[]
TYPE4_10
={
CardType
.
TYPE_TUNER
,
CardType
.
TYPE_EFFECT
,
CardType
.
TYPE_NORMAL
,
};
public
static
CardType
[]
GetMonsterTypes
(
long
type
,
bool
no10
=
false
)
{
var
list
=
new
List
<
CardType
>(
5
);
var
typeList
=
new
List
<
CardType
[
]>
(
5
);
if
(
no10
)
{
typeList
.
Add
(
TYPE1_10
);
typeList
.
Add
(
TYPE2_10
);
typeList
.
Add
(
TYPE3_10
);
typeList
.
Add
(
TYPE4_10
);
typeList
.
Add
(
TYPE4_10
);
}
else
{
typeList
.
Add
(
TYPE1
);
typeList
.
Add
(
TYPE2
);
typeList
.
Add
(
TYPE3
);
typeList
.
Add
(
TYPE4
);
typeList
.
Add
(
TYPE4
);
}
int
count
=
typeList
.
Count
;
for
(
int
i
=
0
;
i
<
count
;
i
++)
{
CardType
[]
types
=
typeList
[
i
];
foreach
(
var
t
in
types
)
{
if
((
type
&
(
long
)
t
)
==
(
long
)
t
)
{
if
(!
list
.
Contains
(
t
))
{
list
.
Add
(
t
);
break
;
}
}
}
}
return
list
.
ToArray
();
}
}
}
DataEditorX/Core/LuaFunction.cs
View file @
44764797
...
...
@@ -6,75 +6,77 @@
*
*/
using
System
;
using
System.Collections.Generic
;
using
System.IO
;
using
System.Text
;
using
System.Collections.Generic
;
using
System.Text.RegularExpressions
;
namespace
DataEditorX
{
/// <summary>
/// Lua 函数查找
/// </summary>
public
class
LuaFunction
{
#
region
日志
log
static
void
ResetLog
()
{
File
.
Delete
(
_logtxt
);
}
static
void
Log
(
string
str
)
{
File
.
AppendAllText
(
_logtxt
,
str
+
Environment
.
NewLine
);
}
#
endregion
#
region
old
functions
/// <summary>
/// Lua 函数查找
/// </summary>
public
class
LuaFunction
{
#
region
日志
log
static
void
ResetLog
()
{
File
.
Delete
(
_logtxt
);
}
static
void
Log
(
string
str
)
{
File
.
AppendAllText
(
_logtxt
,
str
+
Environment
.
NewLine
);
}
#
endregion
#
region
old
functions
static
string
_oldfun
;
static
string
_logtxt
;
static
string
_funclisttxt
;
static
readonly
SortedList
<
string
,
string
>
_funclist
=
new
SortedList
<
string
,
string
>();
static
readonly
SortedList
<
string
,
string
>
_funclist
=
new
SortedList
<
string
,
string
>();
//读取旧函数
public
static
void
Read
(
string
funtxt
)
{
_funclist
.
Clear
();
_oldfun
=
funtxt
;
if
(
File
.
Exists
(
funtxt
))
{
string
[]
lines
=
File
.
ReadAllLines
(
funtxt
);
bool
isFind
=
false
;
string
name
=
""
;
string
desc
=
""
;
foreach
(
string
line
in
lines
)
{
if
(
string
.
IsNullOrEmpty
(
line
)
||
line
.
StartsWith
(
"=="
)
||
line
.
StartsWith
(
"#"
))
{
_funclist
.
Clear
();
_oldfun
=
funtxt
;
if
(
File
.
Exists
(
funtxt
))
{
string
[]
lines
=
File
.
ReadAllLines
(
funtxt
);
bool
isFind
=
false
;
string
name
=
""
;
string
desc
=
""
;
foreach
(
string
line
in
lines
)
{
if
(
string
.
IsNullOrEmpty
(
line
)
||
line
.
StartsWith
(
"=="
)
||
line
.
StartsWith
(
"#"
))
{
continue
;
}
if
(
line
.
StartsWith
(
"●"
))
{
//添加之前的函数
{
//添加之前的函数
AddOldFun
(
name
,
desc
);
int
w
=
line
.
IndexOf
(
"("
);
int
t
=
line
.
IndexOf
(
" "
);
//获取当前名字
if
(
t
<
w
&&
t
>
0
){
name
=
line
.
Substring
(
t
+
1
,
w
-
t
-
1
);
isFind
=
true
;
desc
=
line
.
Replace
(
"●"
,
""
);
}
}
else
if
(
isFind
){
desc
+=
Environment
.
NewLine
+
line
;
}
}
int
w
=
line
.
IndexOf
(
"("
);
int
t
=
line
.
IndexOf
(
" "
);
//获取当前名字
if
(
t
<
w
&&
t
>
0
)
{
name
=
line
.
Substring
(
t
+
1
,
w
-
t
-
1
);
isFind
=
true
;
desc
=
line
.
Replace
(
"●"
,
""
);
}
}
else
if
(
isFind
)
{
desc
+=
Environment
.
NewLine
+
line
;
}
}
AddOldFun
(
name
,
desc
);
}
//return list;
}
}
//return list;
}
static
void
AddOldFun
(
string
name
,
string
desc
)
{
if
(!
string
.
IsNullOrEmpty
(
name
))
...
...
@@ -89,52 +91,56 @@ static void AddOldFun(string name, string desc)
}
}
}
#
endregion
#
region
find
libs
#
endregion
#
region
find
libs
/// <summary>
/// 查找lua函数
/// </summary>
/// <param name="path"></param>
/// <returns></returns>
public
static
bool
Find
(
string
path
)
{
string
name
=
"interpreter.cpp"
;
string
file
=
Path
.
Combine
(
path
,
name
);
string
file2
=
Path
.
Combine
(
Path
.
Combine
(
path
,
"ocgcore"
),
name
);
_logtxt
=
Path
.
Combine
(
path
,
"find_functions.log"
);
ResetLog
();
_funclisttxt
=
Path
.
Combine
(
path
,
"_functions.txt"
);
File
.
Delete
(
_funclisttxt
);
if
(!
File
.
Exists
(
file
)){
//判断用户选择的目录
Log
(
"error: no find file "
+
file
);
if
(
File
.
Exists
(
file2
)){
file
=
file2
;
path
=
Path
.
Combine
(
path
,
"ocgcore"
);
}
else
{
Log
(
"error: no find file "
+
file2
);
return
false
;
}
}
string
texts
=
File
.
ReadAllText
(
file
);
Regex
libRex
=
new
Regex
(
@"\sluaL_Reg\s([a-z]*?)lib\[\]([\s\S]*?)^\}"
,
RegexOptions
.
Multiline
);
MatchCollection
libsMatch
=
libRex
.
Matches
(
texts
);
Log
(
"log:count "
+
libsMatch
.
Count
.
ToString
());
foreach
(
Match
m
in
libsMatch
)
//获取lib函数库
{
if
(
m
.
Groups
.
Count
>
2
){
string
word
=
m
.
Groups
[
1
].
Value
;
Log
(
"log:find "
+
word
);
public
static
bool
Find
(
string
path
)
{
string
name
=
"interpreter.cpp"
;
string
file
=
Path
.
Combine
(
path
,
name
);
string
file2
=
Path
.
Combine
(
Path
.
Combine
(
path
,
"ocgcore"
),
name
);
_logtxt
=
Path
.
Combine
(
path
,
"find_functions.log"
);
ResetLog
();
_funclisttxt
=
Path
.
Combine
(
path
,
"_functions.txt"
);
File
.
Delete
(
_funclisttxt
);
if
(!
File
.
Exists
(
file
))
{
//判断用户选择的目录
Log
(
"error: no find file "
+
file
);
if
(
File
.
Exists
(
file2
))
{
file
=
file2
;
path
=
Path
.
Combine
(
path
,
"ocgcore"
);
}
else
{
Log
(
"error: no find file "
+
file2
);
return
false
;
}
}
string
texts
=
File
.
ReadAllText
(
file
);
Regex
libRex
=
new
Regex
(
@"\sluaL_Reg\s([a-z]*?)lib\[\]([\s\S]*?)^\}"
,
RegexOptions
.
Multiline
);
MatchCollection
libsMatch
=
libRex
.
Matches
(
texts
);
Log
(
"log:count "
+
libsMatch
.
Count
.
ToString
());
foreach
(
Match
m
in
libsMatch
)
//获取lib函数库
{
if
(
m
.
Groups
.
Count
>
2
)
{
string
word
=
m
.
Groups
[
1
].
Value
;
Log
(
"log:find "
+
word
);
//分别去获取函数库的函数
GetFunctions
(
word
,
m
.
Groups
[
2
].
Value
,
Path
.
Combine
(
path
,
"lib"
+
word
+
".cpp"
));
}
}
Save
();
return
true
;
}
GetFunctions
(
word
,
m
.
Groups
[
2
].
Value
,
Path
.
Combine
(
path
,
"lib"
+
word
+
".cpp"
));
}
}
Save
();
return
true
;
}
//保存
static
void
Save
()
{
...
...
@@ -156,256 +162,259 @@ static void Save()
}
}
#
endregion
#
region
find
function
name
static
string
ToTitle
(
string
str
)
{
return
str
.
Substring
(
0
,
1
).
ToUpper
()+
str
.
Substring
(
1
);
}
#
endregion
#
region
find
function
name
static
string
ToTitle
(
string
str
)
{
return
str
.
Substring
(
0
,
1
).
ToUpper
()
+
str
.
Substring
(
1
);
}
//获取函数库的lua函数名,和对应的c++函数
static
Dictionary
<
string
,
string
>
GetFunctionNames
(
string
texts
,
string
name
)
{
Dictionary
<
string
,
string
>
dic
=
new
Dictionary
<
string
,
string
>();
Regex
funcRex
=
new
Regex
(
"\"(\\S*?)\",\\s*?(\\S*?::\\S*?)\\s"
);
MatchCollection
funcsMatch
=
funcRex
.
Matches
(
texts
);
Log
(
"log: functions count "
+
name
+
":"
+
funcsMatch
.
Count
.
ToString
());
foreach
(
Match
m
in
funcsMatch
)
{
if
(
m
.
Groups
.
Count
>
2
)
{
string
k
=
ToTitle
(
name
)+
"."
+
m
.
Groups
[
1
].
Value
;
string
v
=
m
.
Groups
[
2
].
Value
;
if
(!
dic
.
ContainsKey
(
k
))
static
Dictionary
<
string
,
string
>
GetFunctionNames
(
string
texts
,
string
name
)
{
Dictionary
<
string
,
string
>
dic
=
new
Dictionary
<
string
,
string
>();
Regex
funcRex
=
new
Regex
(
"\"(\\S*?)\",\\s*?(\\S*?::\\S*?)\\s"
);
MatchCollection
funcsMatch
=
funcRex
.
Matches
(
texts
);
Log
(
"log: functions count "
+
name
+
":"
+
funcsMatch
.
Count
.
ToString
());
foreach
(
Match
m
in
funcsMatch
)
{
if
(
m
.
Groups
.
Count
>
2
)
{
string
k
=
ToTitle
(
name
)+
"."
+
m
.
Groups
[
1
].
Value
;
string
v
=
m
.
Groups
[
2
].
Value
;
if
(!
dic
.
ContainsKey
(
k
))
{
dic
.
Add
(
k
,
v
);
dic
.
Add
(
k
,
v
);
}
}
}
return
dic
;
}
#
endregion
#
region
find
code
}
return
dic
;
}
#
endregion
#
region
find
code
//查找c++代码
static
string
FindCode
(
string
texts
,
string
name
)
{
Regex
reg
=
new
Regex
(
@"int32\s+?"
+
name
+
@"[\s\S]+?\{([\s\S]*?^)\}"
,
RegexOptions
.
Multiline
);
Match
mc
=
reg
.
Match
(
texts
);
if
(
mc
.
Success
)
{
if
(
mc
.
Groups
.
Count
>
1
)
static
string
FindCode
(
string
texts
,
string
name
)
{
Regex
reg
=
new
Regex
(
@"int32\s+?"
+
name
+
@"[\s\S]+?\{([\s\S]*?^)\}"
,
RegexOptions
.
Multiline
);
Match
mc
=
reg
.
Match
(
texts
);
if
(
mc
.
Success
)
{
if
(
mc
.
Groups
.
Count
>
1
)
{
return
mc
.
Groups
[
0
].
Value
.
Replace
(
"\r\n"
,
"\n"
)
.
Replace
(
"\r"
,
"\n"
)
.
Replace
(
"\n"
,
Environment
.
NewLine
);
.
Replace
(
"\r\n"
,
"\n"
)
.
Replace
(
"\r"
,
"\n"
)
.
Replace
(
"\n"
,
Environment
.
NewLine
);
}
}
return
""
;
}
#
endregion
#
region
find
return
return
""
;
}
#
endregion
#
region
find
return
//查找返回类型
static
string
FindReturn
(
string
texts
)
{
string
restr
=
""
;
if
(
texts
.
IndexOf
(
"lua_pushboolean"
)>=
0
)
static
string
FindReturn
(
string
texts
)
{
string
restr
=
""
;
if
(
texts
.
IndexOf
(
"lua_pushboolean"
)
>=
0
)
{
return
"bool "
;
}
else
{
if
(
texts
.
IndexOf
(
"interpreter::card2value"
)>=
0
)
{
if
(
texts
.
IndexOf
(
"interpreter::card2value"
)
>=
0
)
{
restr
+=
"Card "
;
}
if
(
texts
.
IndexOf
(
"interpreter::group2value"
)
>=
0
)
if
(
texts
.
IndexOf
(
"interpreter::group2value"
)
>=
0
)
{
restr
+=
"Group "
;
}
if
(
texts
.
IndexOf
(
"interpreter::effect2value"
)
>=
0
)
if
(
texts
.
IndexOf
(
"interpreter::effect2value"
)
>=
0
)
{
restr
+=
"Effect "
;
}
else
if
(
texts
.
IndexOf
(
"interpreter::function2value"
)>=
0
)
else
if
(
texts
.
IndexOf
(
"interpreter::function2value"
)
>=
0
)
{
restr
+=
"function "
;
}
if
(
texts
.
IndexOf
(
"lua_pushinteger"
)
>=
0
)
if
(
texts
.
IndexOf
(
"lua_pushinteger"
)
>=
0
)
{
restr
+=
"int "
;
}
if
(
texts
.
IndexOf
(
"lua_pushstring"
)
>=
0
)
if
(
texts
.
IndexOf
(
"lua_pushstring"
)
>=
0
)
{
restr
+=
"string "
;
}
}
if
(
string
.
IsNullOrEmpty
(
restr
))
if
(
string
.
IsNullOrEmpty
(
restr
))
{
restr
=
"void "
;
restr
=
"void "
;
}
if
(
restr
.
IndexOf
(
" "
)
!=
restr
.
Length
-
1
){
restr
=
restr
.
Replace
(
" "
,
"|"
).
Substring
(
0
,
restr
.
Length
-
1
)+
" "
;
}
return
restr
;
}
#
endregion
#
region
find
args
if
(
restr
.
IndexOf
(
" "
)
!=
restr
.
Length
-
1
)
{
restr
=
restr
.
Replace
(
" "
,
"|"
).
Substring
(
0
,
restr
.
Length
-
1
)
+
" "
;
}
return
restr
;
}
#
endregion
#
region
find
args
//查找参数
static
string
getUserType
(
string
str
)
{
if
(
str
.
IndexOf
(
"card"
)>=
0
)
static
string
getUserType
(
string
str
)
{
if
(
str
.
IndexOf
(
"card"
)
>=
0
)
{
return
"Card"
;
}
if
(
str
.
IndexOf
(
"effect"
)
>=
0
)
if
(
str
.
IndexOf
(
"effect"
)
>=
0
)
{
return
"Effect"
;
}
if
(
str
.
IndexOf
(
"group"
)
>=
0
)
if
(
str
.
IndexOf
(
"group"
)
>=
0
)
{
return
"Group"
;
}
return
"Any"
;
}
static
void
AddArgs
(
string
texts
,
string
regx
,
string
arg
,
SortedList
<
int
,
string
>
dic
)
{
//function
Regex
reg
=
new
Regex
(
regx
);
MatchCollection
mcs
=
reg
.
Matches
(
texts
);
foreach
(
Match
m
in
mcs
)
{
if
(
m
.
Groups
.
Count
>
1
)
{
string
v
=
arg
;
int
k
=
int
.
Parse
(
m
.
Groups
[
1
].
Value
);
if
(
dic
.
ContainsKey
(
k
))
}
static
void
AddArgs
(
string
texts
,
string
regx
,
string
arg
,
SortedList
<
int
,
string
>
dic
)
{
//function
Regex
reg
=
new
Regex
(
regx
);
MatchCollection
mcs
=
reg
.
Matches
(
texts
);
foreach
(
Match
m
in
mcs
)
{
if
(
m
.
Groups
.
Count
>
1
)
{
string
v
=
arg
;
int
k
=
int
.
Parse
(
m
.
Groups
[
1
].
Value
);
if
(
dic
.
ContainsKey
(
k
))
{
dic
[
k
]
=
dic
[
k
]
+
"|"
+
v
;
dic
[
k
]
=
dic
[
k
]
+
"|"
+
v
;
}
else
{
dic
.
Add
(
k
,
v
);
dic
.
Add
(
k
,
v
);
}
}
}
}
static
string
FindArgs
(
string
texts
)
{
SortedList
<
int
,
string
>
dic
=
new
SortedList
<
int
,
string
>();
//card effect ggroup
Regex
reg
=
new
Regex
(
@"\((\S+?)\)\s+?lua_touserdata\(L,\s+(\d+)\)"
);
MatchCollection
mcs
=
reg
.
Matches
(
texts
);
foreach
(
Match
m
in
mcs
)
{
if
(
m
.
Groups
.
Count
>
2
)
{
string
v
=
m
.
Groups
[
1
].
Value
.
ToLower
();
v
=
getUserType
(
v
);
int
k
=
int
.
Parse
(
m
.
Groups
[
2
].
Value
);
if
(
dic
.
ContainsKey
(
k
))
}
}
static
string
FindArgs
(
string
texts
)
{
SortedList
<
int
,
string
>
dic
=
new
SortedList
<
int
,
string
>();
//card effect ggroup
Regex
reg
=
new
Regex
(
@"\((\S+?)\)\s+?lua_touserdata\(L,\s+(\d+)\)"
);
MatchCollection
mcs
=
reg
.
Matches
(
texts
);
foreach
(
Match
m
in
mcs
)
{
if
(
m
.
Groups
.
Count
>
2
)
{
string
v
=
m
.
Groups
[
1
].
Value
.
ToLower
();
v
=
getUserType
(
v
);
int
k
=
int
.
Parse
(
m
.
Groups
[
2
].
Value
);
if
(
dic
.
ContainsKey
(
k
))
{
dic
[
k
]
=
dic
[
k
]
+
"|"
+
v
;
dic
[
k
]
=
dic
[
k
]
+
"|"
+
v
;
}
else
{
dic
.
Add
(
k
,
v
);
dic
.
Add
(
k
,
v
);
}
}
}
//function
AddArgs
(
texts
,
@"interpreter::get_function_handle\(L,\s+(\d+)\)"
,
"function"
,
dic
);
//int
AddArgs
(
texts
,
@"lua_tointeger\(L,\s+(\d+)\)"
,
"integer"
,
dic
);
//string
AddArgs
(
texts
,
@"lua_tostring\(L,\s+(\d+)\)"
,
"string"
,
dic
);
//bool
AddArgs
(
texts
,
@"lua_toboolean\(L,\s+(\d+)\)"
,
"boolean"
,
dic
);
}
//function
AddArgs
(
texts
,
@"interpreter::get_function_handle\(L,\s+(\d+)\)"
,
"function"
,
dic
);
//int
AddArgs
(
texts
,
@"lua_tointeger\(L,\s+(\d+)\)"
,
"integer"
,
dic
);
//string
AddArgs
(
texts
,
@"lua_tostring\(L,\s+(\d+)\)"
,
"string"
,
dic
);
//bool
AddArgs
(
texts
,
@"lua_toboolean\(L,\s+(\d+)\)"
,
"boolean"
,
dic
);
string
args
=
"("
;
foreach
(
int
i
in
dic
.
Keys
)
{
args
+=
dic
[
i
]+
", "
;
}
if
(
args
.
Length
>
1
)
string
args
=
"("
;
foreach
(
int
i
in
dic
.
Keys
)
{
args
+=
dic
[
i
]
+
", "
;
}
if
(
args
.
Length
>
1
)
{
args
=
args
.
Substring
(
0
,
args
.
Length
-
2
);
args
=
args
.
Substring
(
0
,
args
.
Length
-
2
);
}
args
+=
")"
;
return
args
;
}
#
endregion
#
region
find
old
return
args
;
}
#
endregion
#
region
find
old
//查找旧函数的描述
static
string
FindOldDesc
(
string
name
)
{
if
(
_funclist
.
ContainsKey
(
name
))
static
string
FindOldDesc
(
string
name
)
{
if
(
_funclist
.
ContainsKey
(
name
))
{
return
_funclist
[
name
];
}
return
""
;
}
#
endregion
#
region
Save
Functions
}
#
endregion
#
region
Save
Functions
//保存函数
public
static
void
GetFunctions
(
string
name
,
string
texts
,
string
file
)
{
if
(!
File
.
Exists
(
file
)){
Log
(
"error:no find file "
+
file
);
return
;
}
string
cpps
=
File
.
ReadAllText
(
file
);
//lua name /cpp name
Dictionary
<
string
,
string
>
fun
=
GetFunctionNames
(
texts
,
name
);
if
(
fun
==
null
||
fun
.
Count
==
0
){
Log
(
"warning: no find functions of "
+
name
);
return
;
}
Log
(
"log: find functions "
+
name
+
":"
+
fun
.
Count
.
ToString
());
public
static
void
GetFunctions
(
string
name
,
string
texts
,
string
file
)
{
if
(!
File
.
Exists
(
file
))
{
Log
(
"error:no find file "
+
file
);
return
;
}
string
cpps
=
File
.
ReadAllText
(
file
);
//lua name /cpp name
Dictionary
<
string
,
string
>
fun
=
GetFunctionNames
(
texts
,
name
);
if
(
fun
==
null
||
fun
.
Count
==
0
)
{
Log
(
"warning: no find functions of "
+
name
);
return
;
}
Log
(
"log: find functions "
+
name
+
":"
+
fun
.
Count
.
ToString
());
using
(
FileStream
fs
=
new
FileStream
(
file
+
".txt"
,
FileMode
.
Create
,
FileAccess
.
Write
))
{
StreamWriter
sw
=
new
StreamWriter
(
fs
,
Encoding
.
UTF8
);
sw
.
WriteLine
(
"========== "
+
name
+
" =========="
);
using
(
FileStream
fs
=
new
FileStream
(
file
+
".txt"
,
FileMode
.
Create
,
FileAccess
.
Write
))
{
StreamWriter
sw
=
new
StreamWriter
(
fs
,
Encoding
.
UTF8
);
sw
.
WriteLine
(
"========== "
+
name
+
" =========="
);
File
.
AppendAllText
(
_funclisttxt
,
"========== "
+
name
+
" =========="
+
Environment
.
NewLine
);
foreach
(
string
k
in
fun
.
Keys
)
{
string
v
=
fun
[
k
];
string
code
=
FindCode
(
cpps
,
v
);
string
txt
=
"●"
+
FindReturn
(
code
)+
k
+
FindArgs
(
code
)
+
Environment
.
NewLine
+
FindOldDesc
(
k
)
+
Environment
.
NewLine
+
code
;
sw
.
WriteLine
(
txt
);
File
.
AppendAllText
(
_funclisttxt
,
txt
+
Environment
.
NewLine
);
}
sw
.
Close
();
}
}
#
endregion
}
foreach
(
string
k
in
fun
.
Keys
)
{
string
v
=
fun
[
k
];
string
code
=
FindCode
(
cpps
,
v
);
string
txt
=
"●"
+
FindReturn
(
code
)+
k
+
FindArgs
(
code
)
+
Environment
.
NewLine
+
FindOldDesc
(
k
)
+
Environment
.
NewLine
+
code
;
sw
.
WriteLine
(
txt
);
File
.
AppendAllText
(
_funclisttxt
,
txt
+
Environment
.
NewLine
);
}
sw
.
Close
();
}
}
#
endregion
}
}
DataEditorX/Core/Mse/CardPack.cs
View file @
44764797
...
...
@@ -6,95 +6,98 @@
*
* 要改变这种模板请点击 工具|选项|代码编写|编辑标准头文件
*/
using
System
;
namespace
DataEditorX.Core
{
/// <summary>
/// Description of CardPack.
/// </summary>
public
class
CardPack
{
public
CardPack
(
long
id
)
{
this
.
CardId
=
id
;
}
public
long
CardId
{
get
;
private
set
;
}
public
string
pack_id
;
public
string
pack_name
;
public
string
rarity
;
public
string
date
;
public
string
GetMseRarity
(){
if
(
this
.
rarity
==
null
)
/// <summary>
/// Description of CardPack.
/// </summary>
public
class
CardPack
{
public
CardPack
(
long
id
)
{
this
.
CardId
=
id
;
}
public
long
CardId
{
get
;
private
set
;
}
public
string
pack_id
;
public
string
pack_name
;
public
string
rarity
;
public
string
date
;
public
string
GetMseRarity
()
{
if
(
this
.
rarity
==
null
)
{
return
"common"
;
}
string
rarity
=
this
.
rarity
.
Trim
().
ToLower
();
if
(
rarity
.
Equals
(
"common"
)
||
rarity
.
Equals
(
"short print"
))
{
return
"common"
;
}
if
(
rarity
.
Equals
(
"rare"
)
||
rarity
.
Equals
(
"normal rare"
))
{
return
"rare"
;
}
else
if
(
rarity
.
Contains
(
"parallel"
)
||
rarity
.
Contains
(
"Kaiba"
)
||
rarity
.
Contains
(
"duel terminal"
))
{
return
"parallel rare"
;
}
else
if
(
rarity
.
Contains
(
"super"
)
||
rarity
.
Contains
(
"holofoil"
))
{
return
"super rare"
;
}
else
if
(
rarity
.
Contains
(
"ultra"
))
{
return
"ultra rare"
;
}
else
if
(
rarity
.
Contains
(
"secret"
))
{
return
"secret rare"
;
}
else
if
(
rarity
.
Contains
(
"gold"
))
{
return
"gold rare"
;
}
else
if
(
rarity
.
Contains
(
"ultimate"
))
{
return
"ultimate rare"
;
}
else
if
(
rarity
.
Contains
(
"prismatic"
))
{
return
"prismatic rare"
;
}
else
if
(
rarity
.
Contains
(
"star"
))
{
return
"star rare"
;
}
else
if
(
rarity
.
Contains
(
"mosaic"
))
{
return
"mosaic rare"
;
}
else
if
(
rarity
.
Contains
(
"platinum"
))
{
return
"platinum rare"
;
}
else
if
(
rarity
.
Contains
(
"ghost"
)
||
rarity
.
Contains
(
"holographic"
))
{
return
"ghost rare"
;
}
else
if
(
rarity
.
Contains
(
"millenium"
))
{
return
"millenium rare"
;
}
if
(
this
.
rarity
.
Contains
(
"/"
)){
return
this
.
rarity
.
Split
(
'/'
)[
0
];
}
return
this
.
rarity
;
}
}
if
(
rarity
.
Equals
(
"common"
)
||
rarity
.
Equals
(
"short print"
))
{
return
"common"
;
}
if
(
rarity
.
Equals
(
"rare"
)
||
rarity
.
Equals
(
"normal rare"
))
{
return
"rare"
;
}
else
if
(
rarity
.
Contains
(
"parallel"
)
||
rarity
.
Contains
(
"Kaiba"
)
||
rarity
.
Contains
(
"duel terminal"
))
{
return
"parallel rare"
;
}
else
if
(
rarity
.
Contains
(
"super"
)
||
rarity
.
Contains
(
"holofoil"
))
{
return
"super rare"
;
}
else
if
(
rarity
.
Contains
(
"ultra"
))
{
return
"ultra rare"
;
}
else
if
(
rarity
.
Contains
(
"secret"
))
{
return
"secret rare"
;
}
else
if
(
rarity
.
Contains
(
"gold"
))
{
return
"gold rare"
;
}
else
if
(
rarity
.
Contains
(
"ultimate"
))
{
return
"ultimate rare"
;
}
else
if
(
rarity
.
Contains
(
"prismatic"
))
{
return
"prismatic rare"
;
}
else
if
(
rarity
.
Contains
(
"star"
))
{
return
"star rare"
;
}
else
if
(
rarity
.
Contains
(
"mosaic"
))
{
return
"mosaic rare"
;
}
else
if
(
rarity
.
Contains
(
"platinum"
))
{
return
"platinum rare"
;
}
else
if
(
rarity
.
Contains
(
"ghost"
)
||
rarity
.
Contains
(
"holographic"
))
{
return
"ghost rare"
;
}
else
if
(
rarity
.
Contains
(
"millenium"
))
{
return
"millenium rare"
;
}
if
(
this
.
rarity
.
Contains
(
"/"
))
{
return
this
.
rarity
.
Split
(
'/'
)[
0
];
}
return
this
.
rarity
;
}
}
}
DataEditorX/Core/Mse/MSEConfig.cs
View file @
44764797
...
...
@@ -5,69 +5,65 @@
* 时间: 15:47
*
*/
using
System
;
using
System.Configuration
;
using
DataEditorX.Common
;
using
DataEditorX.Config
;
using
System.Collections.Generic
;
using
System.IO
;
using
System.Text
;
using
DataEditorX.Language
;
using
System.Globalization
;
using
DataEditorX.Common
;
using
DataEditorX.Config
;
namespace
DataEditorX.Core.Mse
{
/// <summary>
/// Description of MSEConfig.
/// </summary>
public
class
MSEConfig
{
#
region
常量
public
const
string
TAG
=
"mse"
;
/// <summary>存档头部</summary>
public
const
string
TAG_HEAD
=
"head"
;
/// <summary>存档尾部</summary>
public
const
string
TAG_END
=
"end"
;
/// <summary>简体转繁体</summary>
public
const
string
TAG_CN2TW
=
"cn2tw"
;
/// <summary>魔法标志格式</summary>
public
const
string
TAG_SPELL
=
"spell"
;
/// <summary>陷阱标志格式</summary>
public
const
string
TAG_TRAP
=
"trap"
;
public
const
string
TAG_REG_PENDULUM
=
"pendulum-text"
;
public
const
string
TAG_REG_MONSTER
=
"monster-text"
;
public
const
string
TAG_MAXCOUNT
=
"maxcount"
;
public
const
string
TAG_RACE
=
"race"
;
public
const
string
TAG_TYPE
=
"type"
;
public
const
string
TAG_WIDTH
=
"width"
;
public
const
string
TAG_HEIGHT
=
"height"
;
public
const
string
TAG_REIMAGE
=
"reimage"
;
public
const
string
TAG_PEND_WIDTH
=
"pwidth"
;
public
const
string
TAG_PEND_HEIGHT
=
"pheight"
;
/// <summary>
/// Description of MSEConfig.
/// </summary>
public
class
MSEConfig
{
#
region
常量
public
const
string
TAG
=
"mse"
;
/// <summary>存档头部</summary>
public
const
string
TAG_HEAD
=
"head"
;
/// <summary>存档尾部</summary>
public
const
string
TAG_END
=
"end"
;
/// <summary>简体转繁体</summary>
public
const
string
TAG_CN2TW
=
"cn2tw"
;
/// <summary>魔法标志格式</summary>
public
const
string
TAG_SPELL
=
"spell"
;
/// <summary>陷阱标志格式</summary>
public
const
string
TAG_TRAP
=
"trap"
;
public
const
string
TAG_REG_PENDULUM
=
"pendulum-text"
;
public
const
string
TAG_REG_MONSTER
=
"monster-text"
;
public
const
string
TAG_MAXCOUNT
=
"maxcount"
;
public
const
string
TAG_RACE
=
"race"
;
public
const
string
TAG_TYPE
=
"type"
;
public
const
string
TAG_WIDTH
=
"width"
;
public
const
string
TAG_HEIGHT
=
"height"
;
public
const
string
TAG_REIMAGE
=
"reimage"
;
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"
;
public
const
string
TAG_TEXT
=
"text"
;
public
const
string
TAG_NO_TEN
=
"no10"
;
public
const
string
TAG_NO_START_CARDS
=
"no_star_cards"
;
public
const
string
TAG_IMAGE
=
"imagepath"
;
public
const
string
TAG_REPALCE
=
"replace"
;
public
const
string
TAG_TEXT
=
"text"
;
public
const
string
TAG_REP
=
"%%"
;
public
const
string
SEP_LINE
=
" "
;
//默认的配置
public
const
string
FILE_CONFIG_NAME
=
"Chinese-Simplified"
;
public
const
string
PATH_IMAGE
=
"Images"
;
public
string
configName
=
FILE_CONFIG_NAME
;
#
endregion
public
MSEConfig
(
string
path
)
{
public
const
string
TAG_NO_TEN
=
"no10"
;
public
const
string
TAG_NO_START_CARDS
=
"no_star_cards"
;
public
const
string
TAG_REP
=
"%%"
;
public
const
string
SEP_LINE
=
" "
;
//默认的配置
public
const
string
FILE_CONFIG_NAME
=
"Chinese-Simplified"
;
public
const
string
PATH_IMAGE
=
"Images"
;
public
string
configName
=
FILE_CONFIG_NAME
;
#
endregion
public
MSEConfig
(
string
path
)
{
this
.
Init
(
path
);
}
public
void
SetConfig
(
string
config
,
string
path
)
{
if
(!
File
.
Exists
(
config
))
}
public
void
SetConfig
(
string
config
,
string
path
)
{
if
(!
File
.
Exists
(
config
))
{
return
;
}
...
...
@@ -81,10 +77,10 @@ public void SetConfig(string config, string path)
this
.
typeDic
=
new
SortedList
<
long
,
string
>();
this
.
raceDic
=
new
SortedList
<
long
,
string
>();
string
[]
lines
=
File
.
ReadAllLines
(
config
,
Encoding
.
UTF8
);
foreach
(
string
line
in
lines
)
{
if
(
string
.
IsNullOrEmpty
(
line
)
||
line
.
StartsWith
(
"#"
))
string
[]
lines
=
File
.
ReadAllLines
(
config
,
Encoding
.
UTF8
);
foreach
(
string
line
in
lines
)
{
if
(
string
.
IsNullOrEmpty
(
line
)
||
line
.
StartsWith
(
"#"
))
{
continue
;
}
...
...
@@ -125,123 +121,133 @@ public void SetConfig(string config, string path)
{
this
.
maxcount
=
ConfHelper
.
GetIntegerValue
(
line
,
0
);
}
else
if
(
line
.
StartsWith
(
TAG_WIDTH
)){
this
.
width
=
ConfHelper
.
GetIntegerValue
(
line
,
0
);
}
else
if
(
line
.
StartsWith
(
TAG_HEIGHT
)){
this
.
height
=
ConfHelper
.
GetIntegerValue
(
line
,
0
);
}
else
if
(
line
.
StartsWith
(
TAG_PEND_WIDTH
)){
this
.
pwidth
=
ConfHelper
.
GetIntegerValue
(
line
,
0
);
}
else
if
(
line
.
StartsWith
(
TAG_PEND_HEIGHT
)){
this
.
pheight
=
ConfHelper
.
GetIntegerValue
(
line
,
0
);
}
else
if
(
line
.
StartsWith
(
TAG_NO_TEN
)){
else
if
(
line
.
StartsWith
(
TAG_WIDTH
))
{
this
.
width
=
ConfHelper
.
GetIntegerValue
(
line
,
0
);
}
else
if
(
line
.
StartsWith
(
TAG_HEIGHT
))
{
this
.
height
=
ConfHelper
.
GetIntegerValue
(
line
,
0
);
}
else
if
(
line
.
StartsWith
(
TAG_PEND_WIDTH
))
{
this
.
pwidth
=
ConfHelper
.
GetIntegerValue
(
line
,
0
);
}
else
if
(
line
.
StartsWith
(
TAG_PEND_HEIGHT
))
{
this
.
pheight
=
ConfHelper
.
GetIntegerValue
(
line
,
0
);
}
else
if
(
line
.
StartsWith
(
TAG_NO_TEN
))
{
this
.
no10
=
ConfHelper
.
GetBooleanValue
(
line
);
}
else
if
(
line
.
StartsWith
(
TAG_NO_START_CARDS
)){
string
val
=
ConfHelper
.
GetValue
(
line
);
string
[]
cs
=
val
.
Split
(
','
);
this
.
noStartCards
=
new
long
[
cs
.
Length
];
int
i
=
0
;
foreach
(
string
str
in
cs
){
}
else
if
(
line
.
StartsWith
(
TAG_NO_START_CARDS
))
{
string
val
=
ConfHelper
.
GetValue
(
line
);
string
[]
cs
=
val
.
Split
(
','
);
this
.
noStartCards
=
new
long
[
cs
.
Length
];
int
i
=
0
;
foreach
(
string
str
in
cs
)
{
long
.
TryParse
(
str
,
out
long
l
);
this
.
noStartCards
[
i
++]
=
l
;
}
}
else
if
(
line
.
StartsWith
(
TAG_IMAGE
))
{
}
}
else
if
(
line
.
StartsWith
(
TAG_IMAGE
))
{
//如果路径不合法,则为后面的路径
this
.
imagepath
=
MyPath
.
CheckDir
(
ConfHelper
.
GetValue
(
line
),
MyPath
.
Combine
(
path
,
PATH_IMAGE
));
//图片缓存目录
this
.
imagecache
=
MyPath
.
Combine
(
this
.
imagepath
,
"cache"
);
MyPath
.
CreateDir
(
this
.
imagecache
);
}
else
if
(
line
.
StartsWith
(
TAG_REPALCE
))
{
//特数字替换
string
word
=
ConfHelper
.
GetValue
(
line
);
string
p
=
ConfHelper
.
GetRegex
(
ConfHelper
.
GetValue1
(
word
));
string
r
=
ConfHelper
.
GetRegex
(
ConfHelper
.
GetValue2
(
word
));
if
(!
string
.
IsNullOrEmpty
(
p
))
MyPath
.
CreateDir
(
this
.
imagecache
);
}
else
if
(
line
.
StartsWith
(
TAG_REPALCE
))
{
//特数字替换
string
word
=
ConfHelper
.
GetValue
(
line
);
string
p
=
ConfHelper
.
GetRegex
(
ConfHelper
.
GetValue1
(
word
));
string
r
=
ConfHelper
.
GetRegex
(
ConfHelper
.
GetValue2
(
word
));
if
(!
string
.
IsNullOrEmpty
(
p
))
{
this
.
replaces
.
Add
(
p
,
r
);
}
}
else
if
(
line
.
StartsWith
(
TAG_RACE
))
{
//种族
ConfHelper
.
DicAdd
(
this
.
raceDic
,
line
);
}
else
if
(
line
.
StartsWith
(
TAG_TYPE
))
{
//类型
ConfHelper
.
DicAdd
(
this
.
typeDic
,
line
);
}
else
if
(
line
.
StartsWith
(
TAG_REIMAGE
)){
else
if
(
line
.
StartsWith
(
TAG_RACE
))
{
//种族
ConfHelper
.
DicAdd
(
this
.
raceDic
,
line
);
}
else
if
(
line
.
StartsWith
(
TAG_TYPE
))
{
//类型
ConfHelper
.
DicAdd
(
this
.
typeDic
,
line
);
}
else
if
(
line
.
StartsWith
(
TAG_REIMAGE
))
{
this
.
reimage
=
ConfHelper
.
GetBooleanValue
(
line
);
}
}
}
public
void
Init
(
string
path
)
{
}
}
}
public
void
Init
(
string
path
)
{
this
.
Iscn2tw
=
false
;
//读取配置
string
tmp
=
MyPath
.
Combine
(
path
,
MyPath
.
GetFileName
(
TAG
,
MyConfig
.
ReadString
(
MyConfig
.
TAG_MSE
)));
if
(!
File
.
Exists
(
tmp
))
{
tmp
=
MyPath
.
Combine
(
path
,
MyPath
.
GetFileName
(
TAG
,
FILE_CONFIG_NAME
));
if
(!
File
.
Exists
(
tmp
))
//读取配置
string
tmp
=
MyPath
.
Combine
(
path
,
MyPath
.
GetFileName
(
TAG
,
MyConfig
.
ReadString
(
MyConfig
.
TAG_MSE
)));
if
(!
File
.
Exists
(
tmp
))
{
tmp
=
MyPath
.
Combine
(
path
,
MyPath
.
GetFileName
(
TAG
,
FILE_CONFIG_NAME
));
if
(!
File
.
Exists
(
tmp
))
{
return
;
//如果默认的也不存在
}
}
this
.
SetConfig
(
tmp
,
path
);
}
/// <summary>
/// 是否调整图片
/// </summary>
public
bool
reimage
;
/// <summary>
/// 中间图宽度
/// </summary>
public
int
width
;
/// <summary>
/// 中间图高度
/// </summary>
public
int
height
;
public
int
pwidth
;
public
int
pheight
;
//没星星的卡
public
long
[]
noStartCards
;
//第10期
public
bool
no10
;
//每个存档最大数
public
int
maxcount
;
//图片路径
public
string
imagepath
;
/// <summary>
/// 图片缓存路径
/// </summary>
public
string
imagecache
;
//魔法标志
public
string
str_spell
;
//陷阱标志
public
string
str_trap
;
//效果格式
public
string
temp_text
;
//简体转繁体?
public
bool
Iscn2tw
;
//特数字替换
public
SortedList
<
string
,
string
>
replaces
;
//效果文正则提取
public
string
regx_pendulum
;
public
string
regx_monster
;
//存档头部
public
string
head
;
//存档结尾
public
string
end
;
public
SortedList
<
long
,
string
>
typeDic
;
public
SortedList
<
long
,
string
>
raceDic
;
}
}
/// <summary>
/// 是否调整图片
/// </summary>
public
bool
reimage
;
/// <summary>
/// 中间图宽度
/// </summary>
public
int
width
;
/// <summary>
/// 中间图高度
/// </summary>
public
int
height
;
public
int
pwidth
;
public
int
pheight
;
//没星星的卡
public
long
[]
noStartCards
;
//第10期
public
bool
no10
;
//每个存档最大数
public
int
maxcount
;
//图片路径
public
string
imagepath
;
/// <summary>
/// 图片缓存路径
/// </summary>
public
string
imagecache
;
//魔法标志
public
string
str_spell
;
//陷阱标志
public
string
str_trap
;
//效果格式
public
string
temp_text
;
//简体转繁体?
public
bool
Iscn2tw
;
//特数字替换
public
SortedList
<
string
,
string
>
replaces
;
//效果文正则提取
public
string
regx_pendulum
;
public
string
regx_monster
;
//存档头部
public
string
head
;
//存档结尾
public
string
end
;
public
SortedList
<
long
,
string
>
typeDic
;
public
SortedList
<
long
,
string
>
raceDic
;
}
}
DataEditorX/Core/Mse/MSECons.cs
View file @
44764797
using
System
;
using
System.Collections.Generic
;
using
System.Text
;
namespace
DataEditorX.Core.Mse
namespace
DataEditorX.Core.Mse
{
public
class
MseAttribute
{
...
...
DataEditorX/Core/Mse/MseMaker.cs
View file @
44764797
...
...
@@ -5,127 +5,125 @@
* 时间: 12:48
*
*/
using
DataEditorX.Common
;
using
DataEditorX.Core.Info
;
using
DataEditorX.Language
;
using
Microsoft.VisualBasic
;
using
System
;
using
System.IO
;
using
System.Collections.Generic
;
using
System.Drawing
;
using
System.IO
;
using
System.Text
;
using
System.Text.RegularExpressions
;
using
Microsoft.VisualBasic
;
using
System.Drawing
;
using
DataEditorX.Core.Info
;
using
DataEditorX.Config
;
using
DataEditorX.Language
;
using
DataEditorX.Common
;
using
System.Windows.Forms
;
using
System.Threading
;
using
System.Windows.Forms
;
namespace
DataEditorX.Core.Mse
{
/// <summary>
/// MSE制作
/// </summary>
public
class
MseMaker
{
#
region
常量
public
const
string
TAG_CARD
=
"card"
;
public
const
string
TAG_CARDTYPE
=
"card type"
;
public
const
string
TAG_NAME
=
"name"
;
public
const
string
TAG_ATTRIBUTE
=
"attribute"
;
public
const
string
TAG_LEVEL
=
"level"
;
public
const
string
TAG_IMAGE
=
"image"
;
/// <summary>种族</summary>
public
const
string
TAG_TYPE1
=
"type 1"
;
/// <summary>效果1</summary>
public
const
string
TAG_TYPE2
=
"type 2"
;
/// <summary>效果2/summary>
public
const
string
TAG_TYPE3
=
"type 3"
;
/// <summary>效果3</summary>
public
const
string
TAG_TYPE4
=
"type 4"
;
public
const
string
TAG_TYPE5
=
"type 5"
;
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"
;
public
const
string
TAG_PEND_TEXT
=
"pendulum text"
;
public
const
string
TAG_CODE
=
"gamecode"
;
public
const
string
UNKNOWN_ATKDEF
=
"?"
;
public
const
int
UNKNOWN_ATKDEF_VALUE
=
-
2
;
public
const
string
TAG_REP_TEXT
=
"%text%"
;
public
const
string
TAG_REP_PTEXT
=
"%ptext%"
;
/// <summary>
/// MSE制作
/// </summary>
public
class
MseMaker
{
#
region
常量
public
const
string
TAG_CARD
=
"card"
;
public
const
string
TAG_CARDTYPE
=
"card type"
;
public
const
string
TAG_NAME
=
"name"
;
public
const
string
TAG_ATTRIBUTE
=
"attribute"
;
public
const
string
TAG_LEVEL
=
"level"
;
public
const
string
TAG_IMAGE
=
"image"
;
/// <summary>种族</summary>
public
const
string
TAG_TYPE1
=
"type 1"
;
/// <summary>效果1</summary>
public
const
string
TAG_TYPE2
=
"type 2"
;
/// <summary>效果2/summary>
public
const
string
TAG_TYPE3
=
"type 3"
;
/// <summary>效果3</summary>
public
const
string
TAG_TYPE4
=
"type 4"
;
public
const
string
TAG_TYPE5
=
"type 5"
;
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"
;
public
const
string
TAG_PEND_TEXT
=
"pendulum text"
;
public
const
string
TAG_CODE
=
"gamecode"
;
public
const
string
UNKNOWN_ATKDEF
=
"?"
;
public
const
int
UNKNOWN_ATKDEF_VALUE
=
-
2
;
public
const
string
TAG_REP_TEXT
=
"%text%"
;
public
const
string
TAG_REP_PTEXT
=
"%ptext%"
;
public
const
string
TAG_Link_Marker_Up
=
"Link Marker Up"
;
public
const
string
TAG_Link_Marker_UL
=
"Link Marker UL"
;
public
const
string
TAG_Link_Marker_UR
=
"Link Marker UR"
;
public
const
string
TAG_Link_Marker_Down
=
"Link Marker Down"
;
public
const
string
TAG_Link_Marker_DL
=
"Link Marker DL"
;
public
const
string
TAG_Link_Marker_DR
=
"Link Marker DR"
;
public
const
string
TAG_Link_Marker_Left
=
"Link Marker Left"
;
public
const
string
TAG_Link_Marker_Right
=
"Link Marker Right"
;
public
const
string
TAG_Link_Number
=
"link number"
;
#
endregion
public
const
string
TAG_Link_Marker_Up
=
"Link Marker Up"
;
public
const
string
TAG_Link_Marker_UL
=
"Link Marker UL"
;
public
const
string
TAG_Link_Marker_UR
=
"Link Marker UR"
;
public
const
string
TAG_Link_Marker_Down
=
"Link Marker Down"
;
public
const
string
TAG_Link_Marker_DL
=
"Link Marker DL"
;
public
const
string
TAG_Link_Marker_DR
=
"Link Marker DR"
;
public
const
string
TAG_Link_Marker_Left
=
"Link Marker Left"
;
public
const
string
TAG_Link_Marker_Right
=
"Link Marker Right"
;
public
const
string
TAG_Link_Number
=
"link number"
;
#
endregion
#
region
成员,初始化
MSEConfig
cfg
;
public
int
MaxNum
{
get
{
return
this
.
cfg
.
maxcount
;
}
}
#
region
成员,初始化
MSEConfig
cfg
;
public
int
MaxNum
{
get
{
return
this
.
cfg
.
maxcount
;
}
}
public
string
ImagePath
{
get
{
return
this
.
cfg
.
imagepath
;
}
}
public
string
ImagePath
{
get
{
return
this
.
cfg
.
imagepath
;
}
}
public
MseMaker
(
MSEConfig
mcfg
)
{
public
MseMaker
(
MSEConfig
mcfg
)
{
this
.
SetConfig
(
mcfg
);
}
public
void
SetConfig
(
MSEConfig
mcfg
)
{
}
public
void
SetConfig
(
MSEConfig
mcfg
)
{
this
.
cfg
=
mcfg
;
}
public
MSEConfig
GetConfig
()
{
return
this
.
cfg
;
}
#
endregion
}
public
MSEConfig
GetConfig
()
{
return
this
.
cfg
;
}
#
endregion
#
region
数据处理
//合并
public
string
GetLine
(
string
key
,
string
word
)
{
return
" "
+
key
+
": "
+
word
;
}
//特殊字
public
string
ReItalic
(
string
str
)
{
str
=
this
.
CN2TW
(
str
);
foreach
(
string
rs
in
this
.
cfg
.
replaces
.
Keys
)
{
str
=
Regex
.
Replace
(
str
,
rs
,
this
.
cfg
.
replaces
[
rs
]);
}
return
str
;
}
//简体转繁体
public
string
CN2TW
(
string
str
)
{
if
(
this
.
cfg
.
Iscn2tw
)
{
str
=
Strings
.
StrConv
(
str
,
VbStrConv
.
TraditionalChinese
,
0
);
str
=
str
.
Replace
(
"巖"
,
"岩"
);
}
return
str
;
}
//获取魔法陷阱的类型符号
public
string
GetSpellTrapSymbol
(
Card
c
,
bool
isSpell
)
{
string
level
;
if
(
c
.
IsType
(
CardType
.
TYPE_EQUIP
))
#
region
数据处理
//合并
public
string
GetLine
(
string
key
,
string
word
)
{
return
" "
+
key
+
": "
+
word
;
}
//特殊字
public
string
ReItalic
(
string
str
)
{
str
=
this
.
CN2TW
(
str
);
foreach
(
string
rs
in
this
.
cfg
.
replaces
.
Keys
)
{
str
=
Regex
.
Replace
(
str
,
rs
,
this
.
cfg
.
replaces
[
rs
]);
}
return
str
;
}
//简体转繁体
public
string
CN2TW
(
string
str
)
{
if
(
this
.
cfg
.
Iscn2tw
)
{
str
=
Strings
.
StrConv
(
str
,
VbStrConv
.
TraditionalChinese
,
0
);
str
=
str
.
Replace
(
"巖"
,
"岩"
);
}
return
str
;
}
//获取魔法陷阱的类型符号
public
string
GetSpellTrapSymbol
(
Card
c
,
bool
isSpell
)
{
string
level
;
if
(
c
.
IsType
(
CardType
.
TYPE_EQUIP
))
{
level
=
MseSpellTrap
.
EQUIP
;
}
...
...
@@ -168,461 +166,490 @@ public string GetSpellTrapSymbol(Card c, bool isSpell)
}
return
level
;
}
//获取图片路径
public
static
string
GetCardImagePath
(
string
picpath
,
Card
c
)
{
//密码,带0密码,卡名
string
jpg
=
MyPath
.
Combine
(
picpath
,
c
.
id
+
".jpg"
);
string
jpg2
=
MyPath
.
Combine
(
picpath
,
c
.
IdString
+
".jpg"
);
string
jpg3
=
MyPath
.
Combine
(
picpath
,
c
.
name
+
".jpg"
);
string
png
=
MyPath
.
Combine
(
picpath
,
c
.
id
+
".png"
);
string
png2
=
MyPath
.
Combine
(
picpath
,
c
.
IdString
+
".png"
);
string
png3
=
MyPath
.
Combine
(
picpath
,
c
.
name
+
".png"
);
if
(
File
.
Exists
(
jpg
))
{
return
jpg
;
}
else
if
(
File
.
Exists
(
jpg2
))
{
return
jpg2
;
}
else
if
(
File
.
Exists
(
jpg3
))
{
File
.
Copy
(
jpg3
,
jpg
,
true
);
if
(
File
.
Exists
(
jpg
))
{
//复制失败
return
jpg
;
}
}
else
if
(
File
.
Exists
(
png
))
{
return
png
;
}
else
if
(
File
.
Exists
(
png2
))
{
return
png2
;
}
else
if
(
File
.
Exists
(
png3
))
{
File
.
Copy
(
png3
,
png
,
true
);
if
(
File
.
Exists
(
png
))
{
//复制失败
return
png
;
}
}
return
""
;
}
//获取属性
public
static
string
GetAttribute
(
int
attr
)
{
CardAttribute
cattr
=
(
CardAttribute
)
attr
;
string
sattr
=
MseAttribute
.
NONE
;
switch
(
cattr
)
{
case
CardAttribute
.
ATTRIBUTE_DARK
:
sattr
=
MseAttribute
.
DARK
;
break
;
case
CardAttribute
.
ATTRIBUTE_DEVINE
:
sattr
=
MseAttribute
.
DIVINE
;
break
;
case
CardAttribute
.
ATTRIBUTE_EARTH
:
sattr
=
MseAttribute
.
EARTH
;
break
;
case
CardAttribute
.
ATTRIBUTE_FIRE
:
sattr
=
MseAttribute
.
FIRE
;
break
;
case
CardAttribute
.
ATTRIBUTE_LIGHT
:
sattr
=
MseAttribute
.
LIGHT
;
break
;
case
CardAttribute
.
ATTRIBUTE_WATER
:
sattr
=
MseAttribute
.
WATER
;
break
;
case
CardAttribute
.
ATTRIBUTE_WIND
:
sattr
=
MseAttribute
.
WIND
;
break
;
}
return
sattr
;
}
//获取效果文本
public
static
string
GetDesc
(
string
cdesc
,
string
regx
)
{
string
desc
=
cdesc
;
desc
=
desc
.
Replace
(
"\r\n"
,
"\n"
);
desc
=
desc
.
Replace
(
"\r"
,
"\n"
);
Regex
regex
=
new
Regex
(
regx
,
RegexOptions
.
Multiline
);
Match
mc
=
regex
.
Match
(
desc
);
if
(
mc
.
Success
)
}
//获取图片路径
public
static
string
GetCardImagePath
(
string
picpath
,
Card
c
)
{
//密码,带0密码,卡名
string
jpg
=
MyPath
.
Combine
(
picpath
,
c
.
id
+
".jpg"
);
string
jpg2
=
MyPath
.
Combine
(
picpath
,
c
.
IdString
+
".jpg"
);
string
jpg3
=
MyPath
.
Combine
(
picpath
,
c
.
name
+
".jpg"
);
string
png
=
MyPath
.
Combine
(
picpath
,
c
.
id
+
".png"
);
string
png2
=
MyPath
.
Combine
(
picpath
,
c
.
IdString
+
".png"
);
string
png3
=
MyPath
.
Combine
(
picpath
,
c
.
name
+
".png"
);
if
(
File
.
Exists
(
jpg
))
{
return
jpg
;
}
else
if
(
File
.
Exists
(
jpg2
))
{
return
jpg2
;
}
else
if
(
File
.
Exists
(
jpg3
))
{
File
.
Copy
(
jpg3
,
jpg
,
true
);
if
(
File
.
Exists
(
jpg
))
{
//复制失败
return
jpg
;
}
}
else
if
(
File
.
Exists
(
png
))
{
return
png
;
}
else
if
(
File
.
Exists
(
png2
))
{
return
png2
;
}
else
if
(
File
.
Exists
(
png3
))
{
File
.
Copy
(
png3
,
png
,
true
);
if
(
File
.
Exists
(
png
))
{
//复制失败
return
png
;
}
}
return
""
;
}
//获取属性
public
static
string
GetAttribute
(
int
attr
)
{
CardAttribute
cattr
=
(
CardAttribute
)
attr
;
string
sattr
=
MseAttribute
.
NONE
;
switch
(
cattr
)
{
case
CardAttribute
.
ATTRIBUTE_DARK
:
sattr
=
MseAttribute
.
DARK
;
break
;
case
CardAttribute
.
ATTRIBUTE_DEVINE
:
sattr
=
MseAttribute
.
DIVINE
;
break
;
case
CardAttribute
.
ATTRIBUTE_EARTH
:
sattr
=
MseAttribute
.
EARTH
;
break
;
case
CardAttribute
.
ATTRIBUTE_FIRE
:
sattr
=
MseAttribute
.
FIRE
;
break
;
case
CardAttribute
.
ATTRIBUTE_LIGHT
:
sattr
=
MseAttribute
.
LIGHT
;
break
;
case
CardAttribute
.
ATTRIBUTE_WATER
:
sattr
=
MseAttribute
.
WATER
;
break
;
case
CardAttribute
.
ATTRIBUTE_WIND
:
sattr
=
MseAttribute
.
WIND
;
break
;
}
return
sattr
;
}
//获取效果文本
public
static
string
GetDesc
(
string
cdesc
,
string
regx
)
{
string
desc
=
cdesc
;
desc
=
desc
.
Replace
(
"\r\n"
,
"\n"
);
desc
=
desc
.
Replace
(
"\r"
,
"\n"
);
Regex
regex
=
new
Regex
(
regx
,
RegexOptions
.
Multiline
);
Match
mc
=
regex
.
Match
(
desc
);
if
(
mc
.
Success
)
{
return
((
mc
.
Groups
.
Count
>
1
)
?
mc
.
Groups
[
1
].
Value
:
mc
.
Groups
[
0
].
Value
);
mc
.
Groups
[
1
].
Value
:
mc
.
Groups
[
0
].
Value
);
}
return
""
;
}
}
public
string
ReText
(
string
text
)
{
StringBuilder
sb
=
new
StringBuilder
(
text
);
sb
.
Replace
(
"\r\n"
,
"\n"
);
sb
.
Replace
(
"\r"
,
""
);
sb
.
Replace
(
"\n\n"
,
"\n"
);
sb
.
Replace
(
"\n"
,
"\n\t\t"
);
return
sb
.
ToString
().
Trim
(
'\n'
);
}
//获取星星
public
static
string
GetStar
(
long
level
)
{
long
j
=
level
&
0xff
;
string
star
=
""
;
for
(
int
i
=
0
;
i
<
j
;
i
++)
{
star
+=
"*"
;
}
return
star
;
}
//获取种族
public
string
GetRace
(
long
race
)
{
if
(
this
.
cfg
.
raceDic
.
ContainsKey
(
race
))
public
string
ReText
(
string
text
)
{
StringBuilder
sb
=
new
StringBuilder
(
text
);
sb
.
Replace
(
"\r\n"
,
"\n"
);
sb
.
Replace
(
"\r"
,
""
);
sb
.
Replace
(
"\n\n"
,
"\n"
);
sb
.
Replace
(
"\n"
,
"\n\t\t"
);
return
sb
.
ToString
().
Trim
(
'\n'
);
}
//获取星星
public
static
string
GetStar
(
long
level
)
{
long
j
=
level
&
0xff
;
string
star
=
""
;
for
(
int
i
=
0
;
i
<
j
;
i
++)
{
star
+=
"*"
;
}
return
star
;
}
//获取种族
public
string
GetRace
(
long
race
)
{
if
(
this
.
cfg
.
raceDic
.
ContainsKey
(
race
))
{
return
this
.
cfg
.
raceDic
[
race
].
Trim
();
}
return
race
.
ToString
(
"x"
);
}
//获取类型文字
public
string
GetType
(
CardType
ctype
)
{
long
type
=
(
long
)
ctype
;
if
(
this
.
cfg
.
typeDic
.
ContainsKey
(
type
))
}
//获取类型文字
public
string
GetType
(
CardType
ctype
)
{
long
type
=
(
long
)
ctype
;
if
(
this
.
cfg
.
typeDic
.
ContainsKey
(
type
))
{
return
this
.
cfg
.
typeDic
[
type
].
Trim
();
}
return
type
.
ToString
(
"x"
);
}
}
//获取卡片类型
public
string
[]
GetTypes
(
Card
c
)
{
//卡片类型,效果1,效果2,效果3
int
MAX_TYPE
=
5
;
var
types
=
new
string
[
MAX_TYPE
+
1
];
types
[
0
]
=
MseCardType
.
CARD_NORMAL
;
for
(
int
i
=
1
;
i
<
types
.
Length
;
i
++){
types
[
i
]=
""
;
}
if
(
c
.
IsType
(
CardType
.
TYPE_MONSTER
))
{
CardType
[]
cardTypes
=
CardTypes
.
GetMonsterTypes
(
c
.
type
,
this
.
cfg
.
no10
);
int
count
=
cardTypes
.
Length
;
for
(
int
i
=
0
;
i
<
count
&&
i
<
MAX_TYPE
;
i
++){
types
[
i
+
1
]
=
this
.
GetType
(
cardTypes
[
i
]);
}
if
(
cardTypes
.
Length
>
0
){
if
(
c
.
IsType
(
CardType
.
TYPE_LINK
)){
types
[
0
]
=
MseCardType
.
CARD_LINK
;
}
else
if
(
c
.
IsType
(
CardType
.
TYPE_TOKEN
))
{
types
[
0
]
=
(
c
.
race
==
0
)
?
MseCardType
.
CARD_TOKEN2
:
MseCardType
.
CARD_TOKEN
;
}
else
if
(
c
.
IsType
(
CardType
.
TYPE_RITUAL
))
{
types
[
0
]
=
MseCardType
.
CARD_RITUAL
;
}
else
if
(
c
.
IsType
(
CardType
.
TYPE_FUSION
))
{
types
[
0
]
=
MseCardType
.
CARD_FUSION
;
}
else
if
(
c
.
IsType
(
CardType
.
TYPE_SYNCHRO
))
{
types
[
0
]
=
MseCardType
.
CARD_SYNCHRO
;
}
else
if
(
c
.
IsType
(
CardType
.
TYPE_XYZ
))
{
types
[
0
]
=
MseCardType
.
CARD_XYZ
;
}
else
if
(
c
.
IsType
(
CardType
.
TYPE_EFFECT
))
{
types
[
0
]
=
MseCardType
.
CARD_EFFECT
;
}
else
{
types
[
0
]
=
MseCardType
.
CARD_NORMAL
;
if
(
cardTypes
.
Length
==
1
){
//xxx/通常
}
}
}
}
if
(
c
.
race
==
0
)
//如果没有种族
{
types
[
1
]
=
""
;
types
[
2
]
=
""
;
types
[
3
]
=
""
;
types
[
4
]
=
""
;
}
return
types
;
}
#
endregion
//获取卡片类型
public
string
[]
GetTypes
(
Card
c
)
{
//卡片类型,效果1,效果2,效果3
int
MAX_TYPE
=
5
;
var
types
=
new
string
[
MAX_TYPE
+
1
];
types
[
0
]
=
MseCardType
.
CARD_NORMAL
;
for
(
int
i
=
1
;
i
<
types
.
Length
;
i
++)
{
types
[
i
]
=
""
;
}
if
(
c
.
IsType
(
CardType
.
TYPE_MONSTER
))
{
CardType
[]
cardTypes
=
CardTypes
.
GetMonsterTypes
(
c
.
type
,
this
.
cfg
.
no10
);
int
count
=
cardTypes
.
Length
;
for
(
int
i
=
0
;
i
<
count
&&
i
<
MAX_TYPE
;
i
++)
{
types
[
i
+
1
]
=
this
.
GetType
(
cardTypes
[
i
]);
}
if
(
cardTypes
.
Length
>
0
)
{
if
(
c
.
IsType
(
CardType
.
TYPE_LINK
))
{
types
[
0
]
=
MseCardType
.
CARD_LINK
;
}
else
if
(
c
.
IsType
(
CardType
.
TYPE_TOKEN
))
{
types
[
0
]
=
(
c
.
race
==
0
)
?
MseCardType
.
CARD_TOKEN2
:
MseCardType
.
CARD_TOKEN
;
}
else
if
(
c
.
IsType
(
CardType
.
TYPE_RITUAL
))
{
types
[
0
]
=
MseCardType
.
CARD_RITUAL
;
}
else
if
(
c
.
IsType
(
CardType
.
TYPE_FUSION
))
{
types
[
0
]
=
MseCardType
.
CARD_FUSION
;
}
else
if
(
c
.
IsType
(
CardType
.
TYPE_SYNCHRO
))
{
types
[
0
]
=
MseCardType
.
CARD_SYNCHRO
;
}
else
if
(
c
.
IsType
(
CardType
.
TYPE_XYZ
))
{
types
[
0
]
=
MseCardType
.
CARD_XYZ
;
}
else
if
(
c
.
IsType
(
CardType
.
TYPE_EFFECT
))
{
types
[
0
]
=
MseCardType
.
CARD_EFFECT
;
}
else
{
types
[
0
]
=
MseCardType
.
CARD_NORMAL
;
if
(
cardTypes
.
Length
==
1
)
{
//xxx/通常
}
}
}
}
if
(
c
.
race
==
0
)
//如果没有种族
{
types
[
1
]
=
""
;
types
[
2
]
=
""
;
types
[
3
]
=
""
;
types
[
4
]
=
""
;
}
return
types
;
}
#
endregion
#
region
写存档
//写存档
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
>();
string
pic
=
this
.
cfg
.
imagepath
;
using
(
FileStream
fs
=
new
FileStream
(
file
,
FileMode
.
Create
,
FileAccess
.
Write
))
{
StreamWriter
sw
=
new
StreamWriter
(
fs
,
Encoding
.
UTF8
);
sw
.
WriteLine
(
this
.
cfg
.
head
);
foreach
(
Card
c
in
cards
)
{
string
jpg
=
GetCardImagePath
(
pic
,
c
);
if
(!
string
.
IsNullOrEmpty
(
jpg
))
{
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
))
#
region
写存档
//写存档
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
>();
string
pic
=
this
.
cfg
.
imagepath
;
using
(
FileStream
fs
=
new
FileStream
(
file
,
FileMode
.
Create
,
FileAccess
.
Write
))
{
StreamWriter
sw
=
new
StreamWriter
(
fs
,
Encoding
.
UTF8
);
sw
.
WriteLine
(
this
.
cfg
.
head
);
foreach
(
Card
c
in
cards
)
{
string
jpg
=
GetCardImagePath
(
pic
,
c
);
if
(!
string
.
IsNullOrEmpty
(
jpg
))
{
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
(
this
.
getSpellTrap
(
c
,
jpg
,
c
.
IsType
(
CardType
.
TYPE_SPELL
),
cardpack
,
rarity
));
sw
.
WriteLine
(
this
.
getSpellTrap
(
c
,
jpg
,
c
.
IsType
(
CardType
.
TYPE_SPELL
),
cardpack
,
rarity
));
}
else
{
sw
.
WriteLine
(
this
.
getMonster
(
c
,
jpg
,
cardpack
,
rarity
));
sw
.
WriteLine
(
this
.
getMonster
(
c
,
jpg
,
cardpack
,
rarity
));
}
}
sw
.
WriteLine
(
this
.
cfg
.
end
);
sw
.
Close
();
}
sw
.
WriteLine
(
this
.
cfg
.
end
);
sw
.
Close
();
}
return
list
;
}
int
getLinkNumber
(
long
link
){
string
str
=
Convert
.
ToString
(
link
,
2
);
char
[]
cs
=
str
.
ToCharArray
();
int
i
=
0
;
foreach
(
char
c
in
cs
){
if
(
c
==
'1'
){
i
++;
}
}
return
i
;
}
//怪兽,pendulum怪兽
string
getMonster
(
Card
c
,
string
img
,
CardPack
cardpack
=
null
,
bool
rarity
=
true
)
{
StringBuilder
sb
=
new
StringBuilder
();
string
[]
types
=
this
.
GetTypes
(
c
);
string
race
=
this
.
GetRace
(
c
.
race
);
sb
.
AppendLine
(
TAG_CARD
+
":"
);
sb
.
AppendLine
(
this
.
GetLine
(
TAG_CARDTYPE
,
types
[
0
]));
sb
.
AppendLine
(
this
.
GetLine
(
TAG_NAME
,
this
.
ReItalic
(
c
.
name
)));
sb
.
AppendLine
(
this
.
GetLine
(
TAG_ATTRIBUTE
,
GetAttribute
(
c
.
attribute
)));
bool
noStar
=
false
;
if
(
this
.
cfg
.
noStartCards
!=
null
){
foreach
(
long
id
in
this
.
cfg
.
noStartCards
){
if
(
c
.
alias
==
id
||
c
.
id
==
id
){
noStar
=
true
;
break
;
}
}
}
if
(!
noStar
){
sb
.
AppendLine
(
this
.
GetLine
(
TAG_LEVEL
,
GetStar
(
c
.
level
)));
}
sb
.
AppendLine
(
this
.
GetLine
(
TAG_IMAGE
,
img
));
sb
.
AppendLine
(
this
.
GetLine
(
TAG_TYPE1
,
this
.
CN2TW
(
race
)));
sb
.
AppendLine
(
this
.
GetLine
(
TAG_TYPE2
,
this
.
CN2TW
(
types
[
1
])));
sb
.
AppendLine
(
this
.
GetLine
(
TAG_TYPE3
,
this
.
CN2TW
(
types
[
2
])));
sb
.
AppendLine
(
this
.
GetLine
(
TAG_TYPE4
,
this
.
CN2TW
(
types
[
3
])));
sb
.
AppendLine
(
this
.
GetLine
(
TAG_TYPE5
,
this
.
CN2TW
(
types
[
4
])));
if
(
cardpack
!=
null
){
sb
.
AppendLine
(
this
.
GetLine
(
TAG_NUMBER
,
cardpack
.
pack_id
));
if
(
rarity
){
sb
.
AppendLine
(
this
.
GetLine
(
TAG_RARITY
,
cardpack
.
GetMseRarity
()));
}
}
if
(
c
.
IsType
(
CardType
.
TYPE_LINK
)){
if
(
CardLink
.
IsLink
(
c
.
def
,
CardLink
.
DownLeft
)){
sb
.
AppendLine
(
this
.
GetLine
(
TAG_Link_Marker_DL
,
"yes"
));
}
if
(
CardLink
.
IsLink
(
c
.
def
,
CardLink
.
Down
)){
sb
.
AppendLine
(
this
.
GetLine
(
TAG_Link_Marker_Down
,
"yes"
));
}
if
(
CardLink
.
IsLink
(
c
.
def
,
CardLink
.
DownRight
)){
sb
.
AppendLine
(
this
.
GetLine
(
TAG_Link_Marker_DR
,
"yes"
));
}
if
(
CardLink
.
IsLink
(
c
.
def
,
CardLink
.
UpLeft
)){
sb
.
AppendLine
(
this
.
GetLine
(
TAG_Link_Marker_UL
,
"yes"
));
}
if
(
CardLink
.
IsLink
(
c
.
def
,
CardLink
.
Up
)){
sb
.
AppendLine
(
this
.
GetLine
(
TAG_Link_Marker_Up
,
"yes"
));
}
if
(
CardLink
.
IsLink
(
c
.
def
,
CardLink
.
UpRight
)){
sb
.
AppendLine
(
this
.
GetLine
(
TAG_Link_Marker_UR
,
"yes"
));
}
if
(
CardLink
.
IsLink
(
c
.
def
,
CardLink
.
Left
)){
sb
.
AppendLine
(
this
.
GetLine
(
TAG_Link_Marker_Left
,
"yes"
));
}
if
(
CardLink
.
IsLink
(
c
.
def
,
CardLink
.
Right
)){
sb
.
AppendLine
(
this
.
GetLine
(
TAG_Link_Marker_Right
,
"yes"
));
}
sb
.
AppendLine
(
this
.
GetLine
(
TAG_Link_Number
,
""
+
this
.
getLinkNumber
(
c
.
def
)));
sb
.
AppendLine
(
" "
+
TAG_TEXT
+
":"
);
sb
.
AppendLine
(
" "
+
this
.
ReText
(
this
.
ReItalic
(
c
.
desc
)));
}
else
{
if
(
c
.
IsType
(
CardType
.
TYPE_PENDULUM
))
//P怪兽
{
string
text
=
GetDesc
(
c
.
desc
,
this
.
cfg
.
regx_monster
);
if
(
string
.
IsNullOrEmpty
(
text
))
return
list
;
}
int
getLinkNumber
(
long
link
)
{
string
str
=
Convert
.
ToString
(
link
,
2
);
char
[]
cs
=
str
.
ToCharArray
();
int
i
=
0
;
foreach
(
char
c
in
cs
)
{
if
(
c
==
'1'
)
{
i
++;
}
}
return
i
;
}
//怪兽,pendulum怪兽
string
getMonster
(
Card
c
,
string
img
,
CardPack
cardpack
=
null
,
bool
rarity
=
true
)
{
StringBuilder
sb
=
new
StringBuilder
();
string
[]
types
=
this
.
GetTypes
(
c
);
string
race
=
this
.
GetRace
(
c
.
race
);
sb
.
AppendLine
(
TAG_CARD
+
":"
);
sb
.
AppendLine
(
this
.
GetLine
(
TAG_CARDTYPE
,
types
[
0
]));
sb
.
AppendLine
(
this
.
GetLine
(
TAG_NAME
,
this
.
ReItalic
(
c
.
name
)));
sb
.
AppendLine
(
this
.
GetLine
(
TAG_ATTRIBUTE
,
GetAttribute
(
c
.
attribute
)));
bool
noStar
=
false
;
if
(
this
.
cfg
.
noStartCards
!=
null
)
{
foreach
(
long
id
in
this
.
cfg
.
noStartCards
)
{
if
(
c
.
alias
==
id
||
c
.
id
==
id
)
{
noStar
=
true
;
break
;
}
}
}
if
(!
noStar
)
{
sb
.
AppendLine
(
this
.
GetLine
(
TAG_LEVEL
,
GetStar
(
c
.
level
)));
}
sb
.
AppendLine
(
this
.
GetLine
(
TAG_IMAGE
,
img
));
sb
.
AppendLine
(
this
.
GetLine
(
TAG_TYPE1
,
this
.
CN2TW
(
race
)));
sb
.
AppendLine
(
this
.
GetLine
(
TAG_TYPE2
,
this
.
CN2TW
(
types
[
1
])));
sb
.
AppendLine
(
this
.
GetLine
(
TAG_TYPE3
,
this
.
CN2TW
(
types
[
2
])));
sb
.
AppendLine
(
this
.
GetLine
(
TAG_TYPE4
,
this
.
CN2TW
(
types
[
3
])));
sb
.
AppendLine
(
this
.
GetLine
(
TAG_TYPE5
,
this
.
CN2TW
(
types
[
4
])));
if
(
cardpack
!=
null
)
{
sb
.
AppendLine
(
this
.
GetLine
(
TAG_NUMBER
,
cardpack
.
pack_id
));
if
(
rarity
)
{
sb
.
AppendLine
(
this
.
GetLine
(
TAG_RARITY
,
cardpack
.
GetMseRarity
()));
}
}
if
(
c
.
IsType
(
CardType
.
TYPE_LINK
))
{
if
(
CardLink
.
IsLink
(
c
.
def
,
CardLink
.
DownLeft
))
{
sb
.
AppendLine
(
this
.
GetLine
(
TAG_Link_Marker_DL
,
"yes"
));
}
if
(
CardLink
.
IsLink
(
c
.
def
,
CardLink
.
Down
))
{
sb
.
AppendLine
(
this
.
GetLine
(
TAG_Link_Marker_Down
,
"yes"
));
}
if
(
CardLink
.
IsLink
(
c
.
def
,
CardLink
.
DownRight
))
{
sb
.
AppendLine
(
this
.
GetLine
(
TAG_Link_Marker_DR
,
"yes"
));
}
if
(
CardLink
.
IsLink
(
c
.
def
,
CardLink
.
UpLeft
))
{
sb
.
AppendLine
(
this
.
GetLine
(
TAG_Link_Marker_UL
,
"yes"
));
}
if
(
CardLink
.
IsLink
(
c
.
def
,
CardLink
.
Up
))
{
sb
.
AppendLine
(
this
.
GetLine
(
TAG_Link_Marker_Up
,
"yes"
));
}
if
(
CardLink
.
IsLink
(
c
.
def
,
CardLink
.
UpRight
))
{
sb
.
AppendLine
(
this
.
GetLine
(
TAG_Link_Marker_UR
,
"yes"
));
}
if
(
CardLink
.
IsLink
(
c
.
def
,
CardLink
.
Left
))
{
sb
.
AppendLine
(
this
.
GetLine
(
TAG_Link_Marker_Left
,
"yes"
));
}
if
(
CardLink
.
IsLink
(
c
.
def
,
CardLink
.
Right
))
{
sb
.
AppendLine
(
this
.
GetLine
(
TAG_Link_Marker_Right
,
"yes"
));
}
sb
.
AppendLine
(
this
.
GetLine
(
TAG_Link_Number
,
""
+
this
.
getLinkNumber
(
c
.
def
)));
sb
.
AppendLine
(
" "
+
TAG_TEXT
+
":"
);
sb
.
AppendLine
(
" "
+
this
.
ReText
(
this
.
ReItalic
(
c
.
desc
)));
}
else
{
if
(
c
.
IsType
(
CardType
.
TYPE_PENDULUM
))
//P怪兽
{
string
text
=
GetDesc
(
c
.
desc
,
this
.
cfg
.
regx_monster
);
if
(
string
.
IsNullOrEmpty
(
text
))
{
text
=
c
.
desc
;
}
sb
.
AppendLine
(
" "
+
TAG_TEXT
+
":"
);
//sb.AppendLine(cfg.regx_monster + ":" + cfg.regx_pendulum);
sb
.
AppendLine
(
" "
+
this
.
ReText
(
this
.
ReItalic
(
text
)));
sb
.
AppendLine
(
this
.
GetLine
(
TAG_PENDULUM
,
"medium"
));
sb
.
AppendLine
(
this
.
GetLine
(
TAG_PSCALE1
,
((
c
.
level
>>
0x18
)
&
0xff
).
ToString
()));
sb
.
AppendLine
(
this
.
GetLine
(
TAG_PSCALE2
,
((
c
.
level
>>
0x10
)
&
0xff
).
ToString
()));
sb
.
AppendLine
(
" "
+
TAG_PEND_TEXT
+
":"
);
sb
.
AppendLine
(
" "
+
this
.
ReText
(
this
.
ReItalic
(
GetDesc
(
c
.
desc
,
this
.
cfg
.
regx_pendulum
))));
}
else
//一般怪兽
{
sb
.
AppendLine
(
" "
+
TAG_TEXT
+
":"
);
sb
.
AppendLine
(
" "
+
this
.
ReText
(
this
.
ReItalic
(
c
.
desc
)));
}
sb
.
AppendLine
(
this
.
GetLine
(
TAG_DEF
,
(
c
.
def
<
0
)
?
UNKNOWN_ATKDEF
:
c
.
def
.
ToString
()));
}
sb
.
AppendLine
(
this
.
GetLine
(
TAG_ATK
,
(
c
.
atk
<
0
)
?
UNKNOWN_ATKDEF
:
c
.
atk
.
ToString
()));
//sb.AppendLine(cfg.regx_monster + ":" + cfg.regx_pendulum);
sb
.
AppendLine
(
" "
+
this
.
ReText
(
this
.
ReItalic
(
text
)));
sb
.
AppendLine
(
this
.
GetLine
(
TAG_PENDULUM
,
"medium"
));
sb
.
AppendLine
(
this
.
GetLine
(
TAG_PSCALE1
,
((
c
.
level
>>
0x18
)
&
0xff
).
ToString
()));
sb
.
AppendLine
(
this
.
GetLine
(
TAG_PSCALE2
,
((
c
.
level
>>
0x10
)
&
0xff
).
ToString
()));
sb
.
AppendLine
(
" "
+
TAG_PEND_TEXT
+
":"
);
sb
.
AppendLine
(
" "
+
this
.
ReText
(
this
.
ReItalic
(
GetDesc
(
c
.
desc
,
this
.
cfg
.
regx_pendulum
))));
}
else
//一般怪兽
{
sb
.
AppendLine
(
" "
+
TAG_TEXT
+
":"
);
sb
.
AppendLine
(
" "
+
this
.
ReText
(
this
.
ReItalic
(
c
.
desc
)));
}
sb
.
AppendLine
(
this
.
GetLine
(
TAG_DEF
,
(
c
.
def
<
0
)
?
UNKNOWN_ATKDEF
:
c
.
def
.
ToString
()));
}
sb
.
AppendLine
(
this
.
GetLine
(
TAG_ATK
,
(
c
.
atk
<
0
)
?
UNKNOWN_ATKDEF
:
c
.
atk
.
ToString
()));
sb
.
AppendLine
(
this
.
GetLine
(
TAG_CODE
,
c
.
IdString
));
return
sb
.
ToString
();
}
//魔法陷阱
string
getSpellTrap
(
Card
c
,
string
img
,
bool
isSpell
,
CardPack
cardpack
=
null
,
bool
rarity
=
true
)
{
StringBuilder
sb
=
new
StringBuilder
();
sb
.
AppendLine
(
TAG_CARD
+
":"
);
sb
.
AppendLine
(
this
.
GetLine
(
TAG_CARDTYPE
,
isSpell
?
"spell card"
:
"trap card"
));
sb
.
AppendLine
(
this
.
GetLine
(
TAG_NAME
,
this
.
ReItalic
(
c
.
name
)));
sb
.
AppendLine
(
this
.
GetLine
(
TAG_ATTRIBUTE
,
isSpell
?
"spell"
:
"trap"
));
sb
.
AppendLine
(
this
.
GetLine
(
TAG_LEVEL
,
this
.
GetSpellTrapSymbol
(
c
,
isSpell
)));
sb
.
AppendLine
(
this
.
GetLine
(
TAG_IMAGE
,
img
));
if
(
cardpack
!=
null
){
sb
.
AppendLine
(
this
.
GetLine
(
TAG_NUMBER
,
cardpack
.
pack_id
));
if
(
rarity
){
sb
.
AppendLine
(
this
.
GetLine
(
TAG_RARITY
,
cardpack
.
GetMseRarity
()));
}
}
sb
.
AppendLine
(
" "
+
TAG_TEXT
+
":"
);
sb
.
AppendLine
(
" "
+
this
.
ReText
(
this
.
ReItalic
(
c
.
desc
)));
sb
.
AppendLine
(
this
.
GetLine
(
TAG_CODE
,
c
.
IdString
));
return
sb
.
ToString
();
}
#
endregion
sb
.
AppendLine
(
this
.
GetLine
(
TAG_CODE
,
c
.
IdString
));
return
sb
.
ToString
();
}
//魔法陷阱
string
getSpellTrap
(
Card
c
,
string
img
,
bool
isSpell
,
CardPack
cardpack
=
null
,
bool
rarity
=
true
)
{
StringBuilder
sb
=
new
StringBuilder
();
sb
.
AppendLine
(
TAG_CARD
+
":"
);
sb
.
AppendLine
(
this
.
GetLine
(
TAG_CARDTYPE
,
isSpell
?
"spell card"
:
"trap card"
));
sb
.
AppendLine
(
this
.
GetLine
(
TAG_NAME
,
this
.
ReItalic
(
c
.
name
)));
sb
.
AppendLine
(
this
.
GetLine
(
TAG_ATTRIBUTE
,
isSpell
?
"spell"
:
"trap"
));
sb
.
AppendLine
(
this
.
GetLine
(
TAG_LEVEL
,
this
.
GetSpellTrapSymbol
(
c
,
isSpell
)));
sb
.
AppendLine
(
this
.
GetLine
(
TAG_IMAGE
,
img
));
if
(
cardpack
!=
null
)
{
sb
.
AppendLine
(
this
.
GetLine
(
TAG_NUMBER
,
cardpack
.
pack_id
));
if
(
rarity
)
{
sb
.
AppendLine
(
this
.
GetLine
(
TAG_RARITY
,
cardpack
.
GetMseRarity
()));
}
}
sb
.
AppendLine
(
" "
+
TAG_TEXT
+
":"
);
sb
.
AppendLine
(
" "
+
this
.
ReText
(
this
.
ReItalic
(
c
.
desc
)));
sb
.
AppendLine
(
this
.
GetLine
(
TAG_CODE
,
c
.
IdString
));
return
sb
.
ToString
();
}
#
endregion
#
region
读存档
public
static
int
GetAttributeInt
(
string
cattr
)
{
int
iattr
=
0
;
switch
(
cattr
)
{
case
MseAttribute
.
DARK
:
iattr
=
(
int
)
CardAttribute
.
ATTRIBUTE_DARK
;
break
;
case
MseAttribute
.
DIVINE
:
iattr
=
(
int
)
CardAttribute
.
ATTRIBUTE_DEVINE
;
break
;
case
MseAttribute
.
EARTH
:
iattr
=
(
int
)
CardAttribute
.
ATTRIBUTE_EARTH
;
break
;
case
MseAttribute
.
FIRE
:
iattr
=
(
int
)
CardAttribute
.
ATTRIBUTE_FIRE
;
break
;
case
MseAttribute
.
LIGHT
:
iattr
=
(
int
)
CardAttribute
.
ATTRIBUTE_LIGHT
;
break
;
case
MseAttribute
.
WATER
:
iattr
=
(
int
)
CardAttribute
.
ATTRIBUTE_WATER
;
break
;
case
MseAttribute
.
WIND
:
iattr
=
(
int
)
CardAttribute
.
ATTRIBUTE_WIND
;
break
;
}
return
iattr
;
}
long
GetRaceInt
(
string
race
)
{
if
(!
string
.
IsNullOrEmpty
(
race
))
{
foreach
(
long
key
in
this
.
cfg
.
raceDic
.
Keys
)
{
if
(
race
.
Equals
(
this
.
cfg
.
raceDic
[
key
]))
#
region
读存档
public
static
int
GetAttributeInt
(
string
cattr
)
{
int
iattr
=
0
;
switch
(
cattr
)
{
case
MseAttribute
.
DARK
:
iattr
=
(
int
)
CardAttribute
.
ATTRIBUTE_DARK
;
break
;
case
MseAttribute
.
DIVINE
:
iattr
=
(
int
)
CardAttribute
.
ATTRIBUTE_DEVINE
;
break
;
case
MseAttribute
.
EARTH
:
iattr
=
(
int
)
CardAttribute
.
ATTRIBUTE_EARTH
;
break
;
case
MseAttribute
.
FIRE
:
iattr
=
(
int
)
CardAttribute
.
ATTRIBUTE_FIRE
;
break
;
case
MseAttribute
.
LIGHT
:
iattr
=
(
int
)
CardAttribute
.
ATTRIBUTE_LIGHT
;
break
;
case
MseAttribute
.
WATER
:
iattr
=
(
int
)
CardAttribute
.
ATTRIBUTE_WATER
;
break
;
case
MseAttribute
.
WIND
:
iattr
=
(
int
)
CardAttribute
.
ATTRIBUTE_WIND
;
break
;
}
return
iattr
;
}
long
GetRaceInt
(
string
race
)
{
if
(!
string
.
IsNullOrEmpty
(
race
))
{
foreach
(
long
key
in
this
.
cfg
.
raceDic
.
Keys
)
{
if
(
race
.
Equals
(
this
.
cfg
.
raceDic
[
key
]))
{
return
key
;
}
}
}
return
(
long
)
CardRace
.
RACE_NONE
;
}
long
GetTypeInt
(
string
type
)
{
if
(!
string
.
IsNullOrEmpty
(
type
))
{
foreach
(
long
key
in
this
.
cfg
.
typeDic
.
Keys
)
{
if
(
type
.
Equals
(
this
.
cfg
.
typeDic
[
key
]))
}
return
(
long
)
CardRace
.
RACE_NONE
;
}
long
GetTypeInt
(
string
type
)
{
if
(!
string
.
IsNullOrEmpty
(
type
))
{
foreach
(
long
key
in
this
.
cfg
.
typeDic
.
Keys
)
{
if
(
type
.
Equals
(
this
.
cfg
.
typeDic
[
key
]))
{
return
key
;
}
}
}
return
0
;
}
static
string
GetValue
(
string
content
,
string
tag
)
{
Regex
regx
=
new
Regex
(
@"^[\t]+?"
+
tag
+
@":([\s\S]*?)$"
,
RegexOptions
.
Multiline
);
Match
m
=
regx
.
Match
(
content
);
if
(
m
.
Success
)
{
if
(
m
.
Groups
.
Count
>=
2
)
}
return
0
;
}
static
string
GetValue
(
string
content
,
string
tag
)
{
Regex
regx
=
new
Regex
(
@"^[\t]+?"
+
tag
+
@":([\s\S]*?)$"
,
RegexOptions
.
Multiline
);
Match
m
=
regx
.
Match
(
content
);
if
(
m
.
Success
)
{
if
(
m
.
Groups
.
Count
>=
2
)
{
return
RemoveTag
(
m
.
Groups
[
1
].
Value
);
}
}
return
""
;
}
//多行
static
string
GetMultiValue
(
string
content
,
string
tag
)
{
//TODO
content
=
content
.
Replace
(
"\t\t"
,
""
);
Regex
regx
=
new
Regex
(
@"^[\t]+?"
+
tag
+
@":([\S\s]*?)^\t[\S\s]+?:"
,
RegexOptions
.
Multiline
);
Match
m
=
regx
.
Match
(
content
);
if
(
m
.
Success
)
{
if
(
m
.
Groups
.
Count
>=
2
)
{
string
word
=
m
.
Groups
[
1
].
Value
;
return
RemoveTag
(
word
).
Replace
(
"^"
,
""
).
Replace
(
"\t"
,
""
);
}
}
return
""
;
}
long
GetSpellTrapType
(
string
level
)
{
long
type
=
0
;
//魔法陷阱
if
(
level
.
Contains
(
MseSpellTrap
.
EQUIP
))
return
""
;
}
//多行
static
string
GetMultiValue
(
string
content
,
string
tag
)
{
//TODO
content
=
content
.
Replace
(
"\t\t"
,
""
);
Regex
regx
=
new
Regex
(
@"^[\t]+?"
+
tag
+
@":([\S\s]*?)^\t[\S\s]+?:"
,
RegexOptions
.
Multiline
);
Match
m
=
regx
.
Match
(
content
);
if
(
m
.
Success
)
{
if
(
m
.
Groups
.
Count
>=
2
)
{
string
word
=
m
.
Groups
[
1
].
Value
;
return
RemoveTag
(
word
).
Replace
(
"^"
,
""
).
Replace
(
"\t"
,
""
);
}
}
return
""
;
}
long
GetSpellTrapType
(
string
level
)
{
long
type
=
0
;
//魔法陷阱
if
(
level
.
Contains
(
MseSpellTrap
.
EQUIP
))
{
type
=
(
long
)
CardType
.
TYPE_EQUIP
;
}
...
...
@@ -653,10 +680,10 @@ long GetSpellTrapType(string level)
}
return
type
;
}
}
long
GetMonsterType
(
string
cardtype
)
{
long
GetMonsterType
(
string
cardtype
)
{
long
type
;
if
(
cardtype
.
Equals
(
MseCardType
.
CARD_SPELL
))
{
...
...
@@ -667,66 +694,66 @@ long GetMonsterType(string cardtype)
type
=
(
long
)
CardType
.
TYPE_TRAP
;
}
else
{
type
=
(
long
)
CardType
.
TYPE_MONSTER
;
switch
(
cardtype
)
{
case
MseCardType
.
CARD_NORMAL
:
type
|=
(
long
)
CardType
.
TYPE_NORMAL
;
break
;
case
MseCardType
.
CARD_EFFECT
:
type
|=
(
long
)
CardType
.
TYPE_EFFECT
;
break
;
case
MseCardType
.
CARD_XYZ
:
type
|=
(
long
)
CardType
.
TYPE_XYZ
;
break
;
case
MseCardType
.
CARD_RITUAL
:
type
|=
(
long
)
CardType
.
TYPE_RITUAL
;
break
;
case
MseCardType
.
CARD_FUSION
:
type
|=
(
long
)
CardType
.
TYPE_FUSION
;
break
;
case
MseCardType
.
CARD_TOKEN
:
case
MseCardType
.
CARD_TOKEN2
:
type
|=
(
long
)
CardType
.
TYPE_TOKEN
;
break
;
case
MseCardType
.
CARD_SYNCHRO
:
type
|=
(
long
)
CardType
.
TYPE_SYNCHRO
;
break
;
default
:
type
|=
(
long
)
CardType
.
TYPE_NORMAL
;
break
;
}
}
return
type
;
}
//卡片类型
long
GetCardType
(
string
cardtype
,
string
level
,
params
string
[]
types
)
{
long
type
=
0
;
//魔法陷阱
type
|=
this
.
GetSpellTrapType
(
level
);
//怪兽
type
|=
this
.
GetMonsterType
(
cardtype
);
//types是识别怪兽效果类型
foreach
(
string
typ
in
types
)
{
type
=
(
long
)
CardType
.
TYPE_MONSTER
;
switch
(
cardtype
)
{
case
MseCardType
.
CARD_NORMAL
:
type
|=
(
long
)
CardType
.
TYPE_NORMAL
;
break
;
case
MseCardType
.
CARD_EFFECT
:
type
|=
(
long
)
CardType
.
TYPE_EFFECT
;
break
;
case
MseCardType
.
CARD_XYZ
:
type
|=
(
long
)
CardType
.
TYPE_XYZ
;
break
;
case
MseCardType
.
CARD_RITUAL
:
type
|=
(
long
)
CardType
.
TYPE_RITUAL
;
break
;
case
MseCardType
.
CARD_FUSION
:
type
|=
(
long
)
CardType
.
TYPE_FUSION
;
break
;
case
MseCardType
.
CARD_TOKEN
:
case
MseCardType
.
CARD_TOKEN2
:
type
|=
(
long
)
CardType
.
TYPE_TOKEN
;
break
;
case
MseCardType
.
CARD_SYNCHRO
:
type
|=
(
long
)
CardType
.
TYPE_SYNCHRO
;
break
;
default
:
type
|=
(
long
)
CardType
.
TYPE_NORMAL
;
break
;
}
}
return
type
;
}
//卡片类型
long
GetCardType
(
string
cardtype
,
string
level
,
params
string
[]
types
)
{
long
type
=
0
;
//魔法陷阱
type
|=
this
.
GetSpellTrapType
(
level
);
//怪兽
type
|=
this
.
GetMonsterType
(
cardtype
);
//types是识别怪兽效果类型
foreach
(
string
typ
in
types
)
{
type
|=
this
.
GetTypeInt
(
typ
);
}
return
type
;
}
}
static
string
RemoveTag
(
string
word
)
{
//移除标签<>
word
=
Regex
.
Replace
(
word
,
"<[^>]+?>"
,
""
);
return
word
.
Trim
().
Replace
(
"\t"
,
""
);
}
//解析卡片
public
Card
ReadCard
(
string
content
,
out
string
img
)
{
string
tmp
;
static
string
RemoveTag
(
string
word
)
{
//移除标签<>
word
=
Regex
.
Replace
(
word
,
"<[^>]+?>"
,
""
);
return
word
.
Trim
().
Replace
(
"\t"
,
""
);
}
//解析卡片
public
Card
ReadCard
(
string
content
,
out
string
img
)
{
string
tmp
;
Card
c
=
new
Card
{
ot
=
(
int
)
CardRule
.
OCGTCG
,
...
...
@@ -734,29 +761,29 @@ public Card ReadCard(string content, out string img)
name
=
GetValue
(
content
,
TAG_NAME
)
};
tmp
=
GetValue
(
content
,
TAG_LEVEL
);
//卡片种族
c
.
race
=
this
.
GetRaceInt
(
GetValue
(
content
,
TAG_TYPE1
));
//卡片类型
c
.
type
=
this
.
GetCardType
(
GetValue
(
content
,
TAG_CARDTYPE
),
tmp
,
GetValue
(
content
,
TAG_TYPE2
),
GetValue
(
content
,
TAG_TYPE3
),
GetValue
(
content
,
TAG_TYPE4
),
GetValue
(
content
,
TAG_TYPE5
));
long
t
=
this
.
GetSpellTrapType
(
GetValue
(
content
,
TAG_LEVEL
));
//不是魔法,陷阱卡片的星数
if
(!(
c
.
IsType
(
CardType
.
TYPE_SPELL
)
||
c
.
IsType
(
CardType
.
TYPE_TRAP
))
&&
t
==
0
)
//卡片种族
c
.
race
=
this
.
GetRaceInt
(
GetValue
(
content
,
TAG_TYPE1
));
//卡片类型
c
.
type
=
this
.
GetCardType
(
GetValue
(
content
,
TAG_CARDTYPE
),
tmp
,
GetValue
(
content
,
TAG_TYPE2
),
GetValue
(
content
,
TAG_TYPE3
),
GetValue
(
content
,
TAG_TYPE4
),
GetValue
(
content
,
TAG_TYPE5
));
long
t
=
this
.
GetSpellTrapType
(
GetValue
(
content
,
TAG_LEVEL
));
//不是魔法,陷阱卡片的星数
if
(!(
c
.
IsType
(
CardType
.
TYPE_SPELL
)
||
c
.
IsType
(
CardType
.
TYPE_TRAP
))
&&
t
==
0
)
{
c
.
level
=
GetValue
(
content
,
TAG_LEVEL
).
Length
;
}
//属性
c
.
attribute
=
GetAttributeInt
(
GetValue
(
content
,
TAG_ATTRIBUTE
));
//密码
long
.
TryParse
(
GetValue
(
content
,
TAG_CODE
),
out
c
.
id
);
//ATK
tmp
=
GetValue
(
content
,
TAG_ATK
);
if
(
tmp
==
UNKNOWN_ATKDEF
)
//密码
long
.
TryParse
(
GetValue
(
content
,
TAG_CODE
),
out
c
.
id
);
//ATK
tmp
=
GetValue
(
content
,
TAG_ATK
);
if
(
tmp
==
UNKNOWN_ATKDEF
)
{
c
.
atk
=
UNKNOWN_ATKDEF_VALUE
;
}
...
...
@@ -766,7 +793,7 @@ public Card ReadCard(string content, out string img)
}
//DEF
tmp
=
GetValue
(
content
,
TAG_DEF
);
if
(
tmp
==
UNKNOWN_ATKDEF
)
if
(
tmp
==
UNKNOWN_ATKDEF
)
{
c
.
def
=
UNKNOWN_ATKDEF_VALUE
;
}
...
...
@@ -776,46 +803,46 @@ public Card ReadCard(string content, out string img)
}
//图片
img
=
GetValue
(
content
,
TAG_IMAGE
);
//摇摆
if
(
c
.
IsType
(
CardType
.
TYPE_PENDULUM
))
{
//根据预设的模版,替换内容
tmp
=
this
.
cfg
.
temp_text
.
Replace
(
TAG_REP_TEXT
,
GetMultiValue
(
content
,
TAG_TEXT
));
tmp
=
tmp
.
Replace
(
TAG_REP_PTEXT
,
GetMultiValue
(
content
,
TAG_PEND_TEXT
));
c
.
desc
=
tmp
;
}
else
{
c
.
desc
=
GetMultiValue
(
content
,
TAG_TEXT
);
//摇摆
if
(
c
.
IsType
(
CardType
.
TYPE_PENDULUM
))
{
//根据预设的模版,替换内容
tmp
=
this
.
cfg
.
temp_text
.
Replace
(
TAG_REP_TEXT
,
GetMultiValue
(
content
,
TAG_TEXT
));
tmp
=
tmp
.
Replace
(
TAG_REP_PTEXT
,
GetMultiValue
(
content
,
TAG_PEND_TEXT
));
c
.
desc
=
tmp
;
}
else
{
c
.
desc
=
GetMultiValue
(
content
,
TAG_TEXT
);
}
//摇摆刻度
int
.
TryParse
(
GetValue
(
content
,
TAG_PSCALE1
),
out
int
itmp
);
c
.
level
+=
(
itmp
<<
0x18
);
int
.
TryParse
(
GetValue
(
content
,
TAG_PSCALE2
),
out
itmp
);
c
.
level
+=
(
itmp
<<
0x10
);
return
c
;
}
//读取所有卡片
public
Card
[]
ReadCards
(
string
set
,
bool
repalceOld
)
{
List
<
Card
>
cards
=
new
List
<
Card
>();
if
(!
File
.
Exists
(
set
))
c
.
level
+=
(
itmp
<<
0x18
);
int
.
TryParse
(
GetValue
(
content
,
TAG_PSCALE2
),
out
itmp
);
c
.
level
+=
(
itmp
<<
0x10
);
return
c
;
}
//读取所有卡片
public
Card
[]
ReadCards
(
string
set
,
bool
repalceOld
)
{
List
<
Card
>
cards
=
new
List
<
Card
>();
if
(!
File
.
Exists
(
set
))
{
return
null
;
}
string
allcontent
=
File
.
ReadAllText
(
set
,
Encoding
.
UTF8
);
Regex
regx
=
new
Regex
(
@"^card:[\S\s]+?gamecode:[\S\s]+?$"
,
RegexOptions
.
Multiline
);
MatchCollection
matchs
=
regx
.
Matches
(
allcontent
);
int
i
=
0
;
foreach
(
Match
match
in
matchs
)
{
string
content
=
match
.
Groups
[
0
].
Value
;
i
++;
Regex
regx
=
new
Regex
(
@"^card:[\S\s]+?gamecode:[\S\s]+?$"
,
RegexOptions
.
Multiline
);
MatchCollection
matchs
=
regx
.
Matches
(
allcontent
);
int
i
=
0
;
foreach
(
Match
match
in
matchs
)
{
string
content
=
match
.
Groups
[
0
].
Value
;
i
++;
Card
c
=
this
.
ReadCard
(
content
,
out
string
img
);
if
(
c
.
id
<=
0
)
{
...
...
@@ -823,145 +850,168 @@ public Card[] ReadCards(string set, bool repalceOld)
}
//添加卡片
cards
.
Add
(
c
);
//已经解压出来的图片
string
saveimg
=
MyPath
.
Combine
(
this
.
cfg
.
imagepath
,
img
);
if
(!
File
.
Exists
(
saveimg
))
//没有解压相应的图片
//已经解压出来的图片
string
saveimg
=
MyPath
.
Combine
(
this
.
cfg
.
imagepath
,
img
);
if
(!
File
.
Exists
(
saveimg
))
//没有解压相应的图片
{
continue
;
}
//改名后的图片
img
=
MyPath
.
Combine
(
this
.
cfg
.
imagepath
,
c
.
IdString
+
".jpg"
);
if
(
img
==
saveimg
)
//文件名相同
if
(
img
==
saveimg
)
//文件名相同
{
continue
;
}
if
(
File
.
Exists
(
img
))
{
if
(
repalceOld
)
//如果存在,则备份原图
{
File
.
Delete
(
img
+
".bak"
);
//删除备份
File
.
Move
(
img
,
img
+
".bak"
);
//备份
File
.
Move
(
saveimg
,
img
);
//改名
}
}
else
{
if
(
repalceOld
)
//如果存在,则备份原图
{
File
.
Delete
(
img
+
".bak"
);
//删除备份
File
.
Move
(
img
,
img
+
".bak"
);
//备份
File
.
Move
(
saveimg
,
img
);
//改名
}
}
else
{
File
.
Move
(
saveimg
,
img
);
}
}
File
.
Delete
(
set
);
return
cards
.
ToArray
();
}
#
endregion
#
region
images
/// <summary>
/// 图片缓存
/// </summary>
/// <param name="img"></param>
/// <param name="card"></param>
/// <returns></returns>
public
string
GetImageCache
(
string
img
,
Card
card
){
if
(!
this
.
cfg
.
reimage
){
//不需要调整
return
img
;
}
bool
isPendulum
=
card
.
IsType
(
CardType
.
TYPE_PENDULUM
);
if
(
isPendulum
){
if
(
this
.
cfg
.
pwidth
<=
0
&&
this
.
cfg
.
pheight
<=
0
)
File
.
Delete
(
set
);
return
cards
.
ToArray
();
}
#
endregion
#
region
images
/// <summary>
/// 图片缓存
/// </summary>
/// <param name="img"></param>
/// <param name="card"></param>
/// <returns></returns>
public
string
GetImageCache
(
string
img
,
Card
card
)
{
if
(!
this
.
cfg
.
reimage
)
{
//不需要调整
return
img
;
}
bool
isPendulum
=
card
.
IsType
(
CardType
.
TYPE_PENDULUM
);
if
(
isPendulum
)
{
if
(
this
.
cfg
.
pwidth
<=
0
&&
this
.
cfg
.
pheight
<=
0
)
{
return
img
;
}
}
else
{
if
(
this
.
cfg
.
width
<=
0
&&
this
.
cfg
.
height
<=
0
)
else
{
if
(
this
.
cfg
.
width
<=
0
&&
this
.
cfg
.
height
<=
0
)
{
return
img
;
}
}
string
md5
=
MyUtils
.
GetMD5HashFromFile
(
img
);
if
(
MyUtils
.
Md5isEmpty
(
md5
)||
this
.
cfg
.
imagecache
==
null
){
//md5为空
return
img
;
}
string
file
=
MyPath
.
Combine
(
this
.
cfg
.
imagecache
,
md5
);
if
(!
File
.
Exists
(
file
)){
//生成缓存
Bitmap
bmp
=
MyBitmap
.
ReadImage
(
img
);
//缩放
if
(
isPendulum
){
bmp
=
MyBitmap
.
Zoom
(
bmp
,
this
.
cfg
.
pwidth
,
this
.
cfg
.
pheight
);
}
else
{
bmp
=
MyBitmap
.
Zoom
(
bmp
,
this
.
cfg
.
width
,
this
.
cfg
.
height
);
}
//保存文件
MyBitmap
.
SaveAsJPEG
(
bmp
,
file
,
100
);
}
return
file
;
}
#
endregion
#
region
export
static
System
.
Diagnostics
.
Process
_mseProcess
;
static
EventHandler
_exitHandler
;
private
static
void
exportSetThread
(
object
obj
){
string
[]
args
=(
string
[])
obj
;
if
(
args
==
null
||
args
.
Length
<
3
){
string
md5
=
MyUtils
.
GetMD5HashFromFile
(
img
);
if
(
MyUtils
.
Md5isEmpty
(
md5
)
||
this
.
cfg
.
imagecache
==
null
)
{
//md5为空
return
img
;
}
string
file
=
MyPath
.
Combine
(
this
.
cfg
.
imagecache
,
md5
);
if
(!
File
.
Exists
(
file
))
{
//生成缓存
Bitmap
bmp
=
MyBitmap
.
ReadImage
(
img
);
//缩放
if
(
isPendulum
)
{
bmp
=
MyBitmap
.
Zoom
(
bmp
,
this
.
cfg
.
pwidth
,
this
.
cfg
.
pheight
);
}
else
{
bmp
=
MyBitmap
.
Zoom
(
bmp
,
this
.
cfg
.
width
,
this
.
cfg
.
height
);
}
//保存文件
MyBitmap
.
SaveAsJPEG
(
bmp
,
file
,
100
);
}
return
file
;
}
#
endregion
#
region
export
static
System
.
Diagnostics
.
Process
_mseProcess
;
static
EventHandler
_exitHandler
;
private
static
void
exportSetThread
(
object
obj
)
{
string
[]
args
=(
string
[])
obj
;
if
(
args
==
null
||
args
.
Length
<
3
)
{
MessageBox
.
Show
(
LanguageHelper
.
GetMsg
(
LMSG
.
exportMseImagesErr
));
return
;
}
string
mse_path
=
args
[
0
];
string
setfile
=
args
[
1
];
string
path
=
args
[
2
];
if
(
string
.
IsNullOrEmpty
(
mse_path
)||
string
.
IsNullOrEmpty
(
setfile
)){
return
;
}
string
mse_path
=
args
[
0
];
string
setfile
=
args
[
1
];
string
path
=
args
[
2
];
if
(
string
.
IsNullOrEmpty
(
mse_path
)
||
string
.
IsNullOrEmpty
(
setfile
))
{
MessageBox
.
Show
(
LanguageHelper
.
GetMsg
(
LMSG
.
exportMseImagesErr
));
return
;
}
else
{
string
cmd
=
" --export "
+
setfile
.
Replace
(
"\\\\"
,
"\\"
).
Replace
(
"\\"
,
"/"
)+
" {card.gamecode}.png"
;
_mseProcess
=
new
System
.
Diagnostics
.
Process
();
_mseProcess
.
StartInfo
.
FileName
=
mse_path
;
_mseProcess
.
StartInfo
.
Arguments
=
cmd
;
_mseProcess
.
StartInfo
.
WorkingDirectory
=
path
;
_mseProcess
.
EnableRaisingEvents
=
true
;
MyPath
.
CreateDir
(
path
);
try
{
_mseProcess
.
Start
();
//等待结束,需要把当前方法放到线程里面
_mseProcess
.
WaitForExit
();
_mseProcess
.
Exited
+=
new
EventHandler
(
_exitHandler
);
_mseProcess
.
Close
();
_mseProcess
=
null
;
return
;
}
else
{
string
cmd
=
" --export "
+
setfile
.
Replace
(
"\\\\"
,
"\\"
).
Replace
(
"\\"
,
"/"
)+
" {card.gamecode}.png"
;
_mseProcess
=
new
System
.
Diagnostics
.
Process
();
_mseProcess
.
StartInfo
.
FileName
=
mse_path
;
_mseProcess
.
StartInfo
.
Arguments
=
cmd
;
_mseProcess
.
StartInfo
.
WorkingDirectory
=
path
;
_mseProcess
.
EnableRaisingEvents
=
true
;
MyPath
.
CreateDir
(
path
);
try
{
_mseProcess
.
Start
();
//等待结束,需要把当前方法放到线程里面
_mseProcess
.
WaitForExit
();
_mseProcess
.
Exited
+=
new
EventHandler
(
_exitHandler
);
_mseProcess
.
Close
();
_mseProcess
=
null
;
MessageBox
.
Show
(
LanguageHelper
.
GetMsg
(
LMSG
.
exportMseImages
));
}
catch
{
}
}
}
public
static
bool
MseIsRunning
(){
return
_mseProcess
!=
null
;
}
public
static
void
MseStop
(){
try
{
_mseProcess
.
Kill
();
_mseProcess
.
Close
();
}
catch
{}
}
public
static
void
ExportSet
(
string
mse_path
,
string
setfile
,
string
path
,
EventHandler
handler
){
if
(
string
.
IsNullOrEmpty
(
mse_path
)||
setfile
==
null
||
setfile
.
Length
==
0
){
return
;
}
ParameterizedThreadStart
ParStart
=
new
ParameterizedThreadStart
(
exportSetThread
);
}
catch
{
}
}
}
public
static
bool
MseIsRunning
()
{
return
_mseProcess
!=
null
;
}
public
static
void
MseStop
()
{
try
{
_mseProcess
.
Kill
();
_mseProcess
.
Close
();
}
catch
{
}
}
public
static
void
ExportSet
(
string
mse_path
,
string
setfile
,
string
path
,
EventHandler
handler
)
{
if
(
string
.
IsNullOrEmpty
(
mse_path
)
||
setfile
==
null
||
setfile
.
Length
==
0
)
{
return
;
}
ParameterizedThreadStart
ParStart
=
new
ParameterizedThreadStart
(
exportSetThread
);
Thread
myThread
=
new
Thread
(
ParStart
)
{
IsBackground
=
true
};
myThread
.
Start
(
new
string
[]
{
mse_path
,
setfile
,
path
});
_exitHandler
=
handler
;
}
#
endregion
myThread
.
Start
(
new
string
[]
{
mse_path
,
setfile
,
path
});
_exitHandler
=
handler
;
}
#
endregion
public
void
TestPendulum
(
string
desc
)
{
List
<
string
>
table
=
this
.
GetMPText
(
desc
);
...
...
@@ -975,7 +1025,7 @@ public void TestPendulum(string desc)
MessageBox
.
Show
(
this
.
ReItalic
(
table
[
1
]),
"Pendulum Effect"
);
}
}
public
List
<
string
>
GetMPText
(
string
desc
)
{
if
(
string
.
IsNullOrEmpty
(
desc
))
...
...
@@ -1002,12 +1052,12 @@ public List<string> GetMPText(string desc)
text
=
desc
;
}
List
<
string
>
val
=
new
List
<
string
>
{
text
,
ptext
};
return
val
;
List
<
string
>
val
=
new
List
<
string
>
{
text
,
ptext
};
return
val
;
}
}
...
...
@@ -1068,10 +1118,10 @@ public string ReplaceText(string text, string name)
text
=
Regex
.
Replace
(
text
,
thisname
+
@"的灵摆效果在决斗中"
,
"这个卡名的灵摆效果在决斗中"
);
text
=
Regex
.
Replace
(
text
,
thisname
+
@"的([①②③④⑤⑥⑦⑧⑨⑩]+)的"
,
"这个卡名的$1的"
);
text
=
Regex
.
Replace
(
text
,
thisname
+
@"的([①②③④⑤⑥⑦⑧⑨⑩]+)的"
,
"这个卡名的$1的"
);
text
=
Regex
.
Replace
(
text
,
@"作为([①②③④⑤⑥⑦⑧⑨⑩]+)的"
,
"$1的"
);
text
=
Regex
.
Replace
(
text
,
@"作为([①②③④⑤⑥⑦⑧⑨⑩]+)的"
,
"$1的"
);
}
return
text
;
}
}
}
}
DataEditorX/Core/TCGEditor/CardSet.cs
View file @
44764797
using
Newtonsoft.Json
;
using
System
;
using
System.IO
;
using
Newtonsoft.Json
;
namespace
DataEditorX
{
public
class
CardSet
{
public
int
game
;
public
int
version
;
public
MySortList
<
string
,
CardInfo
>
cards
;
}
public
class
CardInfo
{
public
string
title
;
public
string
artwork
;
public
int
[]
artwork_crop
;
/// <summary>
/// ?
/// </summary>
public
int
background
;
/// <summary>
/// ?
/// </summary>
public
int
rarity
;
public
int
attribute
;
public
int
level
;
public
int
icon
;
public
string
description
;
public
string
pendulum_description
;
public
int
[]
pendulum_scales
;
public
string
[]
subtypes
;
public
string
atk
;
public
string
def
;
public
string
edition
;
public
string
@set
;
public
string
card_number
;
public
string
limitation
;
/// <summary>
/// 0,1,1
/// </summary>
public
int
sticker
;
public
string
copyright
;
public
override
string
ToString
()
{
return
string
.
Format
(
"[CardInfo Title={0}, Artwork={1}, Artwork_crop={2}, Background={3}, Rarity={4}, Attribute={5}, Level={6}, Icon={7}, Description={8}, Pendulum_description={9}, Pendulum_scales={10}, Subtypes={11}, Atk={12}, Def={13}, Edition={14}, Set={15}, Card_number={16}, Limitation={17}, Sticker={18}, Copyright={19}]"
,
this
.
title
,
this
.
artwork
,
this
.
artwork_crop
,
this
.
background
,
this
.
rarity
,
this
.
attribute
,
this
.
level
,
this
.
icon
,
this
.
description
,
this
.
pendulum_description
,
this
.
pendulum_scales
,
this
.
subtypes
,
this
.
atk
,
this
.
def
,
this
.
edition
,
this
.
set
,
this
.
card_number
,
this
.
limitation
,
this
.
sticker
,
this
.
copyright
);
}
}
public
class
CardJson
{
public
static
void
Test
(){
string
json
=
File
.
ReadAllText
(
@"F:\TCGEditor_v1.2\t.tcgb"
);
CardSet
cardset
=
JsonConvert
.
DeserializeObject
<
CardSet
>(
json
);
if
(
cardset
.
cards
!=
null
){
int
index
=
0
;
foreach
(
string
key
in
cardset
.
cards
.
Keys
){
Console
.
WriteLine
(
key
);
CardInfo
card
=
cardset
.
cards
.
Values
[
index
];
Console
.
WriteLine
(
card
);
index
++;
}
}
Console
.
ReadKey
();
}
}
public
class
CardSet
{
public
int
game
;
public
int
version
;
public
MySortList
<
string
,
CardInfo
>
cards
;
}
public
class
CardInfo
{
public
string
title
;
public
string
artwork
;
public
int
[]
artwork_crop
;
/// <summary>
/// ?
/// </summary>
public
int
background
;
/// <summary>
/// ?
/// </summary>
public
int
rarity
;
public
int
attribute
;
public
int
level
;
public
int
icon
;
public
string
description
;
public
string
pendulum_description
;
public
int
[]
pendulum_scales
;
public
string
[]
subtypes
;
public
string
atk
;
public
string
def
;
public
string
edition
;
public
string
@set
;
public
string
card_number
;
public
string
limitation
;
/// <summary>
/// 0,1,1
/// </summary>
public
int
sticker
;
public
string
copyright
;
public
override
string
ToString
()
{
return
string
.
Format
(
"[CardInfo Title={0}, Artwork={1}, Artwork_crop={2}, Background={3}, Rarity={4}, Attribute={5}, Level={6}, Icon={7}, Description={8}, Pendulum_description={9}, Pendulum_scales={10}, Subtypes={11}, Atk={12}, Def={13}, Edition={14}, Set={15}, Card_number={16}, Limitation={17}, Sticker={18}, Copyright={19}]"
,
this
.
title
,
this
.
artwork
,
this
.
artwork_crop
,
this
.
background
,
this
.
rarity
,
this
.
attribute
,
this
.
level
,
this
.
icon
,
this
.
description
,
this
.
pendulum_description
,
this
.
pendulum_scales
,
this
.
subtypes
,
this
.
atk
,
this
.
def
,
this
.
edition
,
this
.
set
,
this
.
card_number
,
this
.
limitation
,
this
.
sticker
,
this
.
copyright
);
}
}
public
class
CardJson
{
public
static
void
Test
()
{
string
json
=
File
.
ReadAllText
(
@"F:\TCGEditor_v1.2\t.tcgb"
);
CardSet
cardset
=
JsonConvert
.
DeserializeObject
<
CardSet
>(
json
);
if
(
cardset
.
cards
!=
null
)
{
int
index
=
0
;
foreach
(
string
key
in
cardset
.
cards
.
Keys
)
{
Console
.
WriteLine
(
key
);
CardInfo
card
=
cardset
.
cards
.
Values
[
index
];
Console
.
WriteLine
(
card
);
index
++;
}
}
Console
.
ReadKey
();
}
}
}
\ No newline at end of file
DataEditorX/Core/TaskHelper.cs
View file @
44764797
...
...
@@ -5,160 +5,156 @@
* 时间: 19:43
*
*/
using
System
;
using
DataEditorX.Common
;
using
DataEditorX.Config
;
using
DataEditorX.Core.Info
;
using
DataEditorX.Core.Mse
;
using
DataEditorX.Language
;
using
System.Collections.Generic
;
using
System.Co
nfiguration
;
using
System.Co
mponentModel
;
using
System.Drawing
;
using
System.Drawing.Imaging
;
using
System.IO
;
using
System.IO.Compression
;
using
System.Windows.Forms
;
using
System.ComponentModel
;
using
DataEditorX.Language
;
using
DataEditorX.Common
;
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
this
.
cardlist
;
}
}
/// <summary>
/// 任务参数
/// </summary>
private
string
[]
mArgs
;
/// <summary>
/// 图片设置
/// </summary>
private
readonly
ImageSet
imgSet
;
/// <summary>
/// MSE转换
/// </summary>
private
readonly
MseMaker
mseHelper
;
/// <summary>
/// 是否取消
/// </summary>
private
bool
isCancel
=
false
;
/// <summary>
/// 是否在运行
/// </summary>
private
bool
isRun
=
false
;
/// <summary>
/// 后台工作线程
/// </summary>
private
readonly
BackgroundWorker
worker
;
public
TaskHelper
(
string
datapath
,
BackgroundWorker
worker
,
MSEConfig
mcfg
)
{
this
.
Datapath
=
datapath
;
this
.
worker
=
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
this
.
cardlist
;
}
}
/// <summary>
/// 任务参数
/// </summary>
private
string
[]
mArgs
;
/// <summary>
/// 图片设置
/// </summary>
private
readonly
ImageSet
imgSet
;
/// <summary>
/// MSE转换
/// </summary>
private
readonly
MseMaker
mseHelper
;
/// <summary>
/// 是否取消
/// </summary>
private
bool
isCancel
=
false
;
/// <summary>
/// 是否在运行
/// </summary>
private
bool
isRun
=
false
;
/// <summary>
/// 后台工作线程
/// </summary>
private
readonly
BackgroundWorker
worker
;
public
TaskHelper
(
string
datapath
,
BackgroundWorker
worker
,
MSEConfig
mcfg
)
{
this
.
Datapath
=
datapath
;
this
.
worker
=
worker
;
this
.
mseHelper
=
new
MseMaker
(
mcfg
);
this
.
imgSet
=
new
ImageSet
();
}
public
MseMaker
MseHelper
{
get
{
return
this
.
mseHelper
;
}
}
public
bool
IsRuning
()
{
return
this
.
isRun
;
}
public
bool
IsCancel
()
{
return
this
.
isCancel
;
}
public
void
Cancel
()
{
}
public
MseMaker
MseHelper
{
get
{
return
this
.
mseHelper
;
}
}
public
bool
IsRuning
()
{
return
this
.
isRun
;
}
public
bool
IsCancel
()
{
return
this
.
isCancel
;
}
public
void
Cancel
()
{
this
.
isRun
=
false
;
this
.
isCancel
=
true
;
}
public
MyTask
GetLastTask
()
{
return
this
.
lastTask
;
}
public
void
TestPendulumText
(
string
desc
){
}
public
MyTask
GetLastTask
()
{
return
this
.
lastTask
;
}
public
void
TestPendulumText
(
string
desc
)
{
this
.
mseHelper
.
TestPendulum
(
desc
);
}
#
endregion
}
#
endregion
#
region
Other
//设置任务
public
void
SetTask
(
MyTask
myTask
,
Card
[]
cards
,
params
string
[]
args
)
{
#
region
Other
//设置任务
public
void
SetTask
(
MyTask
myTask
,
Card
[]
cards
,
params
string
[]
args
)
{
this
.
nowTask
=
myTask
;
this
.
cardlist
=
cards
;
this
.
mArgs
=
args
;
}
//转换图片
//public void ToImg(string img, string saveimg1, string saveimg2)
public
void
ToImg
(
string
img
,
string
saveimg1
)
{
if
(!
File
.
Exists
(
img
))
}
//转换图片
//public void ToImg(string img, string saveimg1, string saveimg2)
public
void
ToImg
(
string
img
,
string
saveimg1
)
{
if
(!
File
.
Exists
(
img
))
{
return
;
}
Bitmap
bmp
=
new
Bitmap
(
img
);
MyBitmap
.
SaveAsJPEG
(
MyBitmap
.
Zoom
(
bmp
,
this
.
imgSet
.
W
,
this
.
imgSet
.
H
),
saveimg1
,
this
.
imgSet
.
quilty
);
//MyBitmap.SaveAsJPEG(MyBitmap.Zoom(bmp, imgSet.w, imgSet.h),
// saveimg2, imgSet.quilty);
bmp
.
Dispose
();
}
#
endregion
#
region
检查更新
public
static
void
CheckVersion
(
bool
showNew
)
{
string
newver
=
CheckUpdate
.
GetNewVersion
(
MyConfig
.
ReadString
(
MyConfig
.
TAG_UPDATE_URL
));
if
(
newver
==
CheckUpdate
.
DEFAULT
)
{
//检查失败
if
(!
showNew
)
MyBitmap
.
SaveAsJPEG
(
MyBitmap
.
Zoom
(
bmp
,
this
.
imgSet
.
W
,
this
.
imgSet
.
H
),
saveimg1
,
this
.
imgSet
.
quilty
);
//MyBitmap.SaveAsJPEG(MyBitmap.Zoom(bmp, imgSet.w, imgSet.h),
// saveimg2, imgSet.quilty);
bmp
.
Dispose
();
}
#
endregion
#
region
检查更新
public
static
void
CheckVersion
(
bool
showNew
)
{
string
newver
=
CheckUpdate
.
GetNewVersion
(
MyConfig
.
ReadString
(
MyConfig
.
TAG_UPDATE_URL
));
if
(
newver
==
CheckUpdate
.
DEFAULT
)
{
//检查失败
if
(!
showNew
)
{
return
;
}
MyMsg
.
Error
(
LMSG
.
CheckUpdateFail
);
return
;
}
return
;
}
if
(
CheckUpdate
.
CheckVersion
(
newver
,
Application
.
ProductVersion
))
{
//有最新版本
if
(!
MyMsg
.
Question
(
LMSG
.
HaveNewVersion
))
if
(
CheckUpdate
.
CheckVersion
(
newver
,
Application
.
ProductVersion
))
{
//有最新版本
if
(!
MyMsg
.
Question
(
LMSG
.
HaveNewVersion
))
{
return
;
}
}
else
{
//现在就是最新版本
if
(!
showNew
)
else
{
//现在就是最新版本
if
(!
showNew
)
{
return
;
}
...
...
@@ -168,9 +164,9 @@ public static void CheckVersion(bool showNew)
return
;
}
}
//下载文件
if
(
CheckUpdate
.
DownLoad
(
MyPath
.
Combine
(
Application
.
StartupPath
,
newver
+
".zip"
)))
//下载文件
if
(
CheckUpdate
.
DownLoad
(
MyPath
.
Combine
(
Application
.
StartupPath
,
newver
+
".zip"
)))
{
MyMsg
.
Show
(
LMSG
.
DownloadSucceed
);
}
...
...
@@ -179,243 +175,243 @@ public static void CheckVersion(bool showNew)
MyMsg
.
Show
(
LMSG
.
DownloadFail
);
}
}
public
void
OnCheckUpdate
(
bool
showNew
)
{
public
void
OnCheckUpdate
(
bool
showNew
)
{
CheckVersion
(
showNew
);
}
#
endregion
#
region
裁剪图片
public
void
CutImages
(
string
imgpath
,
bool
isreplace
)
{
int
count
=
this
.
cardlist
.
Length
;
int
i
=
0
;
foreach
(
Card
c
in
this
.
cardlist
)
{
if
(
this
.
isCancel
)
}
#
endregion
#
region
裁剪图片
public
void
CutImages
(
string
imgpath
,
bool
isreplace
)
{
int
count
=
this
.
cardlist
.
Length
;
int
i
=
0
;
foreach
(
Card
c
in
this
.
cardlist
)
{
if
(
this
.
isCancel
)
{
break
;
}
i
++;
this
.
worker
.
ReportProgress
((
i
/
count
),
string
.
Format
(
"{0}/{1}"
,
i
,
count
));
string
jpg
=
MyPath
.
Combine
(
imgpath
,
c
.
id
+
".jpg"
);
string
savejpg
=
MyPath
.
Combine
(
this
.
mseHelper
.
ImagePath
,
c
.
id
+
".jpg"
);
if
(
File
.
Exists
(
jpg
)
&&
(
isreplace
||
!
File
.
Exists
(
savejpg
)))
{
Bitmap
bp
=
new
Bitmap
(
jpg
);
string
jpg
=
MyPath
.
Combine
(
imgpath
,
c
.
id
+
".jpg"
);
string
savejpg
=
MyPath
.
Combine
(
this
.
mseHelper
.
ImagePath
,
c
.
id
+
".jpg"
);
if
(
File
.
Exists
(
jpg
)
&&
(
isreplace
||
!
File
.
Exists
(
savejpg
)))
{
Bitmap
bp
=
new
Bitmap
(
jpg
);
Bitmap
bmp
;
if
(
c
.
IsType
(
CardType
.
TYPE_XYZ
))
//超量
{
bmp
=
MyBitmap
.
Cut
(
bp
,
this
.
imgSet
.
xyzArea
);
}
else
if
(
c
.
IsType
(
CardType
.
TYPE_PENDULUM
))
//P怪兽
{
bmp
=
MyBitmap
.
Cut
(
bp
,
this
.
imgSet
.
pendulumArea
);
}
else
//一般
{
bmp
=
MyBitmap
.
Cut
(
bp
,
this
.
imgSet
.
normalArea
);
}
bp
.
Dispose
();
MyBitmap
.
SaveAsJPEG
(
bmp
,
savejpg
,
this
.
imgSet
.
quilty
);
//bmp.Save(savejpg, ImageFormat.Png);
}
}
}
#
endregion
//removed thumbnail
#
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
(
this
.
isCancel
)
{
bmp
=
MyBitmap
.
Cut
(
bp
,
this
.
imgSet
.
xyzArea
);
}
else
if
(
c
.
IsType
(
CardType
.
TYPE_PENDULUM
))
//P怪兽
{
bmp
=
MyBitmap
.
Cut
(
bp
,
this
.
imgSet
.
pendulumArea
);
}
else
//一般
{
bmp
=
MyBitmap
.
Cut
(
bp
,
this
.
imgSet
.
normalArea
);
}
bp
.
Dispose
();
MyBitmap
.
SaveAsJPEG
(
bmp
,
savejpg
,
this
.
imgSet
.
quilty
);
//bmp.Save(savejpg, ImageFormat.Png);
}
}
}
#
endregion
//removed thumbnail
#
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
(
this
.
isCancel
)
{
break
;
}
i
++;
this
.
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
,
this
.
imgSet
.
W
,
this
.
imgSet
.
H
),
jpg_b
,
this
.
imgSet
.
quilty
);
}
//小图,如果替换,或者不存在
//if (isreplace || !File.Exists(jpg_s))
//{
// MyBitmap.SaveAsJPEG(MyBitmap.Zoom(bmp, imgSet.w, imgSet.h),
// jpg_s, imgSet.quilty);
//}
}
}
}
}
#
endregion
#
region
MSE
存档
public
string
MSEImagePath
{
get
{
return
this
.
mseHelper
.
ImagePath
;
}
}
public
string
Datapath
{
get
;
}
public
void
SaveMSEs
(
string
file
,
Card
[]
cards
,
bool
isUpdate
)
{
if
(
cards
==
null
)
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
,
this
.
imgSet
.
W
,
this
.
imgSet
.
H
),
jpg_b
,
this
.
imgSet
.
quilty
);
}
//小图,如果替换,或者不存在
//if (isreplace || !File.Exists(jpg_s))
//{
// MyBitmap.SaveAsJPEG(MyBitmap.Zoom(bmp, imgSet.w, imgSet.h),
// jpg_s, imgSet.quilty);
//}
}
}
}
}
#
endregion
#
region
MSE
存档
public
string
MSEImagePath
{
get
{
return
this
.
mseHelper
.
ImagePath
;
}
}
public
string
Datapath
{
get
;
}
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
(
this
.
mseHelper
.
MaxNum
==
0
||
c
<
this
.
mseHelper
.
MaxNum
)
bool
rarity
=
MyConfig
.
ReadBoolean
(
"mse_auto_rarity"
,
false
);
#if DEBUG
MessageBox
.
Show
(
"db = "
+
pack_db
+
",auto rarity="
+
rarity
);
#endif
int
c
=
cards
.
Length
;
//不分开,或者卡片数小于单个存档的最大值
if
(
this
.
mseHelper
.
MaxNum
==
0
||
c
<
this
.
mseHelper
.
MaxNum
)
{
this
.
SaveMSE
(
1
,
file
,
cards
,
pack_db
,
rarity
,
isUpdate
);
this
.
SaveMSE
(
1
,
file
,
cards
,
pack_db
,
rarity
,
isUpdate
);
}
else
{
int
nums
=
c
/
this
.
mseHelper
.
MaxNum
;
if
(
nums
*
this
.
mseHelper
.
MaxNum
<
c
)
//计算需要分多少个存档
{
int
nums
=
c
/
this
.
mseHelper
.
MaxNum
;
if
(
nums
*
this
.
mseHelper
.
MaxNum
<
c
)
//计算需要分多少个存档
{
nums
++;
}
List
<
Card
>
clist
=
new
List
<
Card
>();
for
(
int
i
=
0
;
i
<
nums
;
i
++)
//分别生成存档
{
clist
.
Clear
();
for
(
int
j
=
0
;
j
<
this
.
mseHelper
.
MaxNum
;
j
++)
{
int
index
=
i
*
this
.
mseHelper
.
MaxNum
+
j
;
if
(
index
<
c
)
for
(
int
i
=
0
;
i
<
nums
;
i
++)
//分别生成存档
{
clist
.
Clear
();
for
(
int
j
=
0
;
j
<
this
.
mseHelper
.
MaxNum
;
j
++)
{
int
index
=
i
*
this
.
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
);
this
.
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
=
this
.
mseHelper
.
WriteSet
(
setFile
,
cards
,
pack_db
,
rarity
);
if
(
isUpdate
)
//仅更新文字
int
t
=
file
.
LastIndexOf
(
".mse-set"
);
string
fname
=
(
t
>
0
)
?
file
.
Substring
(
0
,
t
)
:
file
;
fname
+=
string
.
Format
(
"_{0}.mse-set"
,
i
+
1
);
this
.
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
=
this
.
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
(
this
.
isCancel
)
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
(
this
.
isCancel
)
{
break
;
}
i
++;
this
.
worker
.
ReportProgress
(
i
/
count
,
string
.
Format
(
"{0}/{1}-{2}"
,
i
,
count
,
num
));
//TODO 先裁剪图片
zips
.
AddFile
(
this
.
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
)
{
//TODO 先裁剪图片
zips
.
AddFile
(
this
.
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
)
{
this
.
worker
.
ReportProgress
(
i
/
count
,
string
.
Format
(
"{0}/{1}"
,
i
,
count
));
string
savefilename
=
MyPath
.
Combine
(
this
.
mseHelper
.
ImagePath
,
file
.
FilenameInZip
);
zips
.
ExtractFile
(
file
,
savefilename
);
}
}
string
setfile
=
MyPath
.
Combine
(
this
.
mseHelper
.
ImagePath
,
"set"
);
return
this
.
mseHelper
.
ReadCards
(
setfile
,
repalceOld
);
}
#
endregion
#
region
导出数据
public
void
ExportData
(
string
path
,
string
zipname
,
string
_cdbfile
,
string
modulescript
)
{
int
i
=
0
;
Card
[]
cards
=
this
.
cardlist
;
if
(
cards
==
null
||
cards
.
Length
==
0
)
string
savefilename
=
MyPath
.
Combine
(
this
.
mseHelper
.
ImagePath
,
file
.
FilenameInZip
);
zips
.
ExtractFile
(
file
,
savefilename
);
}
}
string
setfile
=
MyPath
.
Combine
(
this
.
mseHelper
.
ImagePath
,
"set"
);
return
this
.
mseHelper
.
ReadCards
(
setfile
,
repalceOld
);
}
#
endregion
#
region
导出数据
public
void
ExportData
(
string
path
,
string
zipname
,
string
_cdbfile
,
string
modulescript
)
{
int
i
=
0
;
Card
[]
cards
=
this
.
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
);
//module scripts
string
extra_script
=
""
;
if
(
modulescript
.
Length
>
0
)
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
);
//module scripts
string
extra_script
=
""
;
if
(
modulescript
.
Length
>
0
)
{
extra_script
=
ygopath
.
GetModuleScript
(
modulescript
);
}
File
.
Delete
(
cdbfile
);
DataBase
.
Create
(
cdbfile
);
DataBase
.
CopyDB
(
cdbfile
,
false
,
this
.
cardlist
);
if
(
File
.
Exists
(
zipname
))
DataBase
.
Create
(
cdbfile
);
DataBase
.
CopyDB
(
cdbfile
,
false
,
this
.
cardlist
);
if
(
File
.
Exists
(
zipname
))
{
File
.
Delete
(
zipname
);
}
using
(
ZipStorer
zips
=
ZipStorer
.
Create
(
zipname
,
""
))
{
zips
.
AddFile
(
cdbfile
,
Path
.
GetFileNameWithoutExtension
(
_cdbfile
)
+
".cdb"
,
""
);
if
(
File
.
Exists
(
readme
))
{
zips
.
AddFile
(
cdbfile
,
Path
.
GetFileNameWithoutExtension
(
_cdbfile
)
+
".cdb"
,
""
);
if
(
File
.
Exists
(
readme
))
{
zips
.
AddFile
(
readme
,
"readme_"
+
name
+
".txt"
,
""
);
}
...
...
@@ -431,114 +427,114 @@ public void ExportData(string path, string zipname, string _cdbfile, string modu
}
foreach
(
Card
c
in
cards
)
{
i
++;
{
i
++;
this
.
worker
.
ReportProgress
(
i
/
count
,
string
.
Format
(
"{0}/{1}"
,
i
,
count
));
string
[]
files
=
ygopath
.
GetCardfiles
(
c
.
id
);
foreach
(
string
file
in
files
)
{
if
(!
string
.
Equals
(
file
,
extra_script
)
&&
File
.
Exists
(
file
))
{
zips
.
AddFile
(
file
,
file
.
Replace
(
path
,
""
),
""
);
}
}
}
}
File
.
Delete
(
cdbfile
);
}
#
endregion
#
region
运行
public
void
Run
()
{
string
[]
files
=
ygopath
.
GetCardfiles
(
c
.
id
);
foreach
(
string
file
in
files
)
{
if
(!
string
.
Equals
(
file
,
extra_script
)
&&
File
.
Exists
(
file
))
{
zips
.
AddFile
(
file
,
file
.
Replace
(
path
,
""
),
""
);
}
}
}
}
File
.
Delete
(
cdbfile
);
}
#
endregion
#
region
运行
public
void
Run
()
{
this
.
isCancel
=
false
;
this
.
isRun
=
true
;
bool
replace
;
bool
showNew
;
switch
(
this
.
nowTask
)
{
case
MyTask
.
ExportData
:
if
(
this
.
mArgs
!=
null
&&
this
.
mArgs
.
Length
>=
3
)
{
bool
replace
;
bool
showNew
;
switch
(
this
.
nowTask
)
{
case
MyTask
.
ExportData
:
if
(
this
.
mArgs
!=
null
&&
this
.
mArgs
.
Length
>=
3
)
{
this
.
ExportData
(
this
.
mArgs
[
0
],
this
.
mArgs
[
1
],
this
.
mArgs
[
2
],
this
.
mArgs
[
3
]);
}
break
;
case
MyTask
.
CheckUpdate
:
showNew
=
false
;
if
(
this
.
mArgs
!=
null
&&
this
.
mArgs
.
Length
>=
1
)
{
showNew
=
(
this
.
mArgs
[
0
]
==
bool
.
TrueString
)
?
true
:
false
;
}
}
break
;
case
MyTask
.
CheckUpdate
:
showNew
=
false
;
if
(
this
.
mArgs
!=
null
&&
this
.
mArgs
.
Length
>=
1
)
{
showNew
=
(
this
.
mArgs
[
0
]
==
bool
.
TrueString
)
?
true
:
false
;
}
this
.
OnCheckUpdate
(
showNew
);
break
;
case
MyTask
.
CutImages
:
if
(
this
.
mArgs
!=
null
&&
this
.
mArgs
.
Length
>=
2
)
{
replace
=
true
;
if
(
this
.
mArgs
.
Length
>=
2
)
{
if
(
this
.
mArgs
[
1
]
==
bool
.
FalseString
)
break
;
case
MyTask
.
CutImages
:
if
(
this
.
mArgs
!=
null
&&
this
.
mArgs
.
Length
>=
2
)
{
replace
=
true
;
if
(
this
.
mArgs
.
Length
>=
2
)
{
if
(
this
.
mArgs
[
1
]
==
bool
.
FalseString
)
{
replace
=
false
;
}
}
this
.
CutImages
(
this
.
mArgs
[
0
],
replace
);
}
break
;
case
MyTask
.
SaveAsMSE
:
if
(
this
.
mArgs
!=
null
&&
this
.
mArgs
.
Length
>=
2
)
{
replace
=
false
;
if
(
this
.
mArgs
.
Length
>=
2
)
{
if
(
this
.
mArgs
[
1
]
==
bool
.
TrueString
)
}
break
;
case
MyTask
.
SaveAsMSE
:
if
(
this
.
mArgs
!=
null
&&
this
.
mArgs
.
Length
>=
2
)
{
replace
=
false
;
if
(
this
.
mArgs
.
Length
>=
2
)
{
if
(
this
.
mArgs
[
1
]
==
bool
.
TrueString
)
{
replace
=
true
;
}
}
this
.
SaveMSEs
(
this
.
mArgs
[
0
],
this
.
cardlist
,
replace
);
}
break
;
case
MyTask
.
ReadMSE
:
if
(
this
.
mArgs
!=
null
&&
this
.
mArgs
.
Length
>=
2
)
{
replace
=
false
;
if
(
this
.
mArgs
.
Length
>=
2
)
{
if
(
this
.
mArgs
[
1
]
==
bool
.
TrueString
)
}
break
;
case
MyTask
.
ReadMSE
:
if
(
this
.
mArgs
!=
null
&&
this
.
mArgs
.
Length
>=
2
)
{
replace
=
false
;
if
(
this
.
mArgs
.
Length
>=
2
)
{
if
(
this
.
mArgs
[
1
]
==
bool
.
TrueString
)
{
replace
=
true
;
}
}
this
.
cardlist
=
this
.
ReadMSE
(
this
.
mArgs
[
0
],
replace
);
}
break
;
case
MyTask
.
ConvertImages
:
if
(
this
.
mArgs
!=
null
&&
this
.
mArgs
.
Length
>=
2
)
{
replace
=
true
;
if
(
this
.
mArgs
.
Length
>=
3
)
{
if
(
this
.
mArgs
[
2
]
==
bool
.
FalseString
)
}
break
;
case
MyTask
.
ConvertImages
:
if
(
this
.
mArgs
!=
null
&&
this
.
mArgs
.
Length
>=
2
)
{
replace
=
true
;
if
(
this
.
mArgs
.
Length
>=
3
)
{
if
(
this
.
mArgs
[
2
]
==
bool
.
FalseString
)
{
replace
=
false
;
}
}
this
.
ConvertImages
(
this
.
mArgs
[
0
],
this
.
mArgs
[
1
],
replace
);
}
break
;
}
}
break
;
}
this
.
isRun
=
false
;
this
.
lastTask
=
this
.
nowTask
;
this
.
nowTask
=
MyTask
.
NONE
;
if
(
this
.
lastTask
!=
MyTask
.
ReadMSE
)
if
(
this
.
lastTask
!=
MyTask
.
ReadMSE
)
{
this
.
cardlist
=
null
;
}
this
.
mArgs
=
null
;
}
#
endregion
}
}
#
endregion
}
}
DataEditorX/Core/YGOUtil.cs
View file @
44764797
using
System
;
using
System.Text
;
using
System.IO
;
using
System.Collections.Generic
;
using
System.Text.RegularExpressions
;
using
Microsoft.VisualBasic.FileIO
;
using
System.Configuration
;
using
DataEditorX.Config
;
using
DataEditorX.Config
;
using
DataEditorX.Core.Info
;
using
Microsoft.VisualBasic.FileIO
;
using
System
;
using
System.Collections.Generic
;
using
System.IO
;
using
System.Text
;
namespace
DataEditorX.Core
{
...
...
@@ -250,9 +247,9 @@ public static string[] ReadImage(string path)
public
static
void
CardDelete
(
long
id
,
YgoPath
ygopath
)
{
string
[]
files
=
ygopath
.
GetCardfiles
(
id
);
for
(
int
i
=
0
;
i
<
files
.
Length
;
i
++)
{
if
(
FileSystem
.
FileExists
(
files
[
i
]))
for
(
int
i
=
0
;
i
<
files
.
Length
;
i
++)
{
if
(
FileSystem
.
FileExists
(
files
[
i
]))
{
FileSystem
.
DeleteFile
(
files
[
i
],
UIOption
.
OnlyErrorDialogs
,
RecycleOption
.
SendToRecycleBin
);
}
...
...
@@ -271,32 +268,34 @@ public static void CardRename(long newid, long oldid, YgoPath ygopath)
{
if
(
File
.
Exists
(
oldfiles
[
i
]))
{
try
{
File
.
Move
(
oldfiles
[
i
],
newfiles
[
i
]);
}
catch
{
}
try
{
File
.
Move
(
oldfiles
[
i
],
newfiles
[
i
]);
}
catch
{
}
}
}
}
#
endregion
#
endregion
#
region
复制资源
public
static
void
CardCopy
(
long
newid
,
long
oldid
,
YgoPath
ygopath
)
{
string
[]
newfiles
=
ygopath
.
GetCardfiles
(
newid
);
string
[]
oldfiles
=
ygopath
.
GetCardfiles
(
oldid
);
#
region
复制资源
public
static
void
CardCopy
(
long
newid
,
long
oldid
,
YgoPath
ygopath
)
{
string
[]
newfiles
=
ygopath
.
GetCardfiles
(
newid
);
string
[]
oldfiles
=
ygopath
.
GetCardfiles
(
oldid
);
for
(
int
i
=
0
;
i
<
oldfiles
.
Length
;
i
++)
{
if
(
File
.
Exists
(
oldfiles
[
i
]))
{
try
{
File
.
Copy
(
oldfiles
[
i
],
newfiles
[
i
],
false
);
}
catch
{
}
}
}
}
#
endregion
}
for
(
int
i
=
0
;
i
<
oldfiles
.
Length
;
i
++)
{
if
(
File
.
Exists
(
oldfiles
[
i
]))
{
try
{
File
.
Copy
(
oldfiles
[
i
],
newfiles
[
i
],
false
);
}
catch
{
}
}
}
}
#
endregion
}
}
DataEditorX/DataEditForm.cs
View file @
44764797
...
...
@@ -5,52 +5,51 @@
* 时间: 20:22
*
*/
using
DataEditorX.Common
;
using
DataEditorX.Config
;
using
DataEditorX.Core
;
using
DataEditorX.Core.Mse
;
using
DataEditorX.Language
;
using
System
;
using
System.Collections.Generic
;
using
System.Drawing
;
using
System.Globalization
;
using
System.IO
;
using
System.Windows.Forms
;
using
DataEditorX.Common
;
using
DataEditorX.Config
;
using
DataEditorX.Core
;
using
DataEditorX.Core.Mse
;
using
DataEditorX.Language
;
using
WeifenLuo.WinFormsUI.Docking
;
namespace
DataEditorX
{
public
partial
class
DataEditForm
:
DockContent
,
IDataForm
public
partial
class
DataEditForm
:
DockContent
,
IDataForm
{
private
string
addrequire_str
;
private
string
addrequire_str
;
public
string
Addrequire
{
get
{
if
(!
string
.
IsNullOrEmpty
(
this
.
addrequire_str
))
public
string
Addrequire
{
get
{
if
(!
string
.
IsNullOrEmpty
(
this
.
addrequire_str
))
{
return
this
.
addrequire_str
;
}
else
{
string
cdbName
=
Path
.
GetFileNameWithoutExtension
(
this
.
nowCdbFile
);
if
(
cdbName
.
Length
>
0
&&
File
.
Exists
(
this
.
GetPath
().
GetModuleScript
(
cdbName
)))
{
string
cdbName
=
Path
.
GetFileNameWithoutExtension
(
this
.
nowCdbFile
);
if
(
cdbName
.
Length
>
0
&&
File
.
Exists
(
this
.
GetPath
().
GetModuleScript
(
cdbName
)))
{
return
cdbName
;
}
}
return
""
;
}
set
{
return
""
;
}
set
{
this
.
addrequire_str
=
value
;
}
}
}
}
#
region
成员变量
/
构造
TaskHelper
tasker
=
null
;
#
region
成员变量
/
构造
TaskHelper
tasker
=
null
;
string
taskname
;
//目录
YgoPath
ygopath
;
...
...
@@ -89,7 +88,7 @@ public string Addrequire
string
datapath
,
confcover
;
public
DataEditForm
(
string
datapath
,
string
cdbfile
)
public
DataEditForm
(
string
datapath
,
string
cdbfile
)
{
this
.
Initialize
(
datapath
);
this
.
nowCdbFile
=
cdbfile
;
...
...
@@ -155,11 +154,11 @@ public bool Save()
{
return
true
;
}
#
endregion
#
endregion
#
region
窗体
//窗体第一次加载
void
DataEditFormLoad
(
object
sender
,
EventArgs
e
)
#
region
窗体
//窗体第一次加载
void
DataEditFormLoad
(
object
sender
,
EventArgs
e
)
{
//InitListRows();//调整卡片列表的函数
this
.
HideMenu
();
//是否需要隐藏菜单
...
...
@@ -179,7 +178,7 @@ void DataEditFormLoad(object sender, EventArgs e)
//add require automatically
this
.
Addrequire
=
MyConfig
.
ReadString
(
MyConfig
.
TAG_ADD_REQUIRE
);
this
.
menuitem_addrequire
.
Checked
=
(
this
.
Addrequire
.
Length
>
0
);
if
(
this
.
nowCdbFile
!=
null
&&
File
.
Exists
(
this
.
nowCdbFile
))
if
(
this
.
nowCdbFile
!=
null
&&
File
.
Exists
(
this
.
nowCdbFile
))
{
this
.
Open
(
this
.
nowCdbFile
);
}
...
...
@@ -307,8 +306,8 @@ void InitPath(string datapath)
#
region
界面控件
//初始化控件
public
void
InitControl
(
DataConfig
datacfg
)
{
if
(
datacfg
==
null
)
{
if
(
datacfg
==
null
)
{
return
;
}
...
...
@@ -316,7 +315,7 @@ public void InitControl(DataConfig datacfg)
List
<
long
>
setcodes
=
DataManager
.
GetKeys
(
datacfg
.
dicSetnames
);
string
[]
setnames
=
DataManager
.
GetValues
(
datacfg
.
dicSetnames
);
try
{
{
this
.
InitComboBox
(
this
.
cb_cardrace
,
datacfg
.
dicCardRaces
);
this
.
InitComboBox
(
this
.
cb_cardattribute
,
datacfg
.
dicCardAttributes
);
this
.
InitComboBox
(
this
.
cb_cardrule
,
datacfg
.
dicCardRules
);
...
...
@@ -330,10 +329,10 @@ public void InitControl(DataConfig datacfg)
this
.
InitComboBox
(
this
.
cb_setname3
,
setcodes
,
setnames
);
this
.
InitComboBox
(
this
.
cb_setname4
,
setcodes
,
setnames
);
}
catch
(
Exception
ex
)
{
MessageBox
.
Show
(
ex
.
ToString
(),
"启动错误"
);
}
catch
(
Exception
ex
)
{
MessageBox
.
Show
(
ex
.
ToString
(),
"启动错误"
);
}
}
//初始化FlowLayoutPanel
void
InitCheckPanel
(
FlowLayoutPanel
fpanel
,
Dictionary
<
long
,
string
>
dic
)
...
...
@@ -343,17 +342,20 @@ void InitCheckPanel(FlowLayoutPanel fpanel, Dictionary<long, string> dic)
foreach
(
long
key
in
dic
.
Keys
)
{
string
value
=
dic
[
key
];
if
(
value
!=
null
&&
value
.
StartsWith
(
"NULL"
))
if
(
value
!=
null
&&
value
.
StartsWith
(
"NULL"
))
{
Label
lab
=
new
Label
();
string
[]
sizes
=
value
.
Split
(
','
);
if
(
sizes
.
Length
>=
3
){
lab
.
Size
=
new
Size
(
int
.
Parse
(
sizes
[
1
]),
int
.
Parse
(
sizes
[
2
]));
if
(
sizes
.
Length
>=
3
)
{
lab
.
Size
=
new
Size
(
int
.
Parse
(
sizes
[
1
]),
int
.
Parse
(
sizes
[
2
]));
}
lab
.
AutoSize
=
false
;
lab
.
Margin
=
fpanel
.
Margin
;
fpanel
.
Controls
.
Add
(
lab
);
}
else
{
}
else
{
CheckBox
_cbox
=
new
CheckBox
{
//_cbox.Name = fpanel.Name + key.ToString("x");
...
...
@@ -374,7 +376,7 @@ void InitCheckPanel(FlowLayoutPanel fpanel, Dictionary<long, string> dic)
void
InitComboBox
(
ComboBox
cb
,
Dictionary
<
long
,
string
>
tempdic
)
{
this
.
InitComboBox
(
cb
,
DataManager
.
GetKeys
(
tempdic
),
DataManager
.
GetValues
(
tempdic
));
DataManager
.
GetValues
(
tempdic
));
}
//初始化ComboBox
void
InitComboBox
(
ComboBox
cb
,
List
<
long
>
keys
,
string
[]
values
)
...
...
@@ -383,7 +385,7 @@ void InitComboBox(ComboBox cb, List<long> keys, string[] values)
cb
.
Tag
=
keys
;
cb
.
Items
.
AddRange
(
values
);
if
(
cb
.
Items
.
Count
>
0
)
{
{
cb
.
SelectedIndex
=
0
;
}
}
...
...
@@ -404,12 +406,14 @@ void InitListRows()
if
(
itemH
>
0
)
{
int
n
=
(
this
.
lv_cardlist
.
Height
-
headH
)
/
itemH
;
if
(
n
>
0
){
if
(
n
>
0
)
{
this
.
maxRow
=
n
;
}
//MessageBox.Show("height="+lv_cardlist.Height+",item="+itemH+",head="+headH+",max="+MaxRow);
}
if
(
addTest
){
if
(
addTest
)
{
this
.
lv_cardlist
.
Items
.
Clear
();
}
if
(
this
.
maxRow
<
10
)
...
...
@@ -586,16 +590,16 @@ public Card GetOldCard()
{
return
this
.
oldCard
;
}
private
void
setLinkMarks
(
long
mark
,
bool
setCheck
=
false
)
private
void
setLinkMarks
(
long
mark
,
bool
setCheck
=
false
)
{
if
(
setCheck
)
if
(
setCheck
)
{
this
.
SetCheck
(
this
.
pl_markers
,
mark
);
}
this
.
tb_link
.
Text
=
Convert
.
ToString
(
mark
,
2
).
PadLeft
(
9
,
'0'
);
this
.
tb_link
.
Text
=
Convert
.
ToString
(
mark
,
2
).
PadLeft
(
9
,
'0'
);
}
public
void
SetCard
(
Card
c
)
{
this
.
oldCard
=
c
;
...
...
@@ -621,11 +625,13 @@ public void SetCard(Card c)
this
.
tb_setcode4
.
Text
=
setcodes
[
3
].
ToString
(
"x"
);
//type,category
this
.
SetCheck
(
this
.
pl_cardtype
,
c
.
type
);
if
(
c
.
IsType
(
Core
.
Info
.
CardType
.
TYPE_LINK
)){
if
(
c
.
IsType
(
Core
.
Info
.
CardType
.
TYPE_LINK
))
{
this
.
setLinkMarks
(
c
.
def
,
true
);
}
else
{
this
.
tb_link
.
Text
=
""
;
else
{
this
.
tb_link
.
Text
=
""
;
this
.
SetCheck
(
this
.
pl_markers
,
0
);
}
this
.
SetCheck
(
this
.
pl_category
,
c
.
category
);
...
...
@@ -898,11 +904,11 @@ void Search(Card c, bool isfresh)
string
sql
=
DataBase
.
GetSelectSQL
(
c
);
this
.
SetCards
(
DataBase
.
Read
(
this
.
nowCdbFile
,
true
,
sql
),
isfresh
);
}
if
(
this
.
lv_cardlist
.
Items
.
Count
>
0
)
{
if
(
this
.
lv_cardlist
.
Items
.
Count
>
0
)
{
this
.
lv_cardlist
.
SelectedIndices
.
Clear
();
this
.
lv_cardlist
.
SelectedIndices
.
Add
(
0
);
}
}
}
//更新临时卡片
public
void
Reset
()
...
...
@@ -1002,10 +1008,10 @@ void Tb_cardnameKeyDown(object sender, KeyEventArgs e)
this
.
Search
(
c
,
false
);
}
}
if
(
e
.
KeyCode
==
Keys
.
R
&&
e
.
Control
)
{
if
(
e
.
KeyCode
==
Keys
.
R
&&
e
.
Control
)
{
this
.
Btn_resetClick
(
null
,
null
);
}
}
}
//卡片描述编辑
void
Setscripttext
(
string
str
)
...
...
@@ -1167,7 +1173,7 @@ void Menuitem_readydkClick(object sender, EventArgs e)
string
[]
ids
=
YGOUtil
.
ReadYDK
(
dlg
.
FileName
);
this
.
tmpCodes
.
AddRange
(
ids
);
this
.
SetCards
(
DataBase
.
Read
(
this
.
nowCdbFile
,
true
,
ids
),
false
);
ids
),
false
);
}
}
}
...
...
@@ -1188,7 +1194,7 @@ void Menuitem_readimagesClick(object sender, EventArgs e)
string
[]
ids
=
YGOUtil
.
ReadImage
(
fdlg
.
SelectedPath
);
this
.
tmpCodes
.
AddRange
(
ids
);
this
.
SetCards
(
DataBase
.
Read
(
this
.
nowCdbFile
,
true
,
ids
),
false
);
ids
),
false
);
}
}
}
...
...
@@ -1233,8 +1239,8 @@ void BgWorker1ProgressChanged(object sender, System.ComponentModel.ProgressChang
this
.
title
=
string
.
Format
(
"{0} ({1}-{2})"
,
this
.
RemoveTag
(
this
.
title
),
this
.
taskname
,
// e.ProgressPercentage,
e
.
UserState
);
// e.ProgressPercentage,
e
.
UserState
);
this
.
SetTitle
();
}
//任务完成
...
...
@@ -1318,7 +1324,7 @@ public Card[] GetCardList(bool onlyselect)
index
=
lvitem
.
Index
+
(
this
.
page
-
1
)
*
this
.
maxRow
;
}
if
(
index
>=
0
&&
index
<
this
.
cardlist
.
Count
)
if
(
index
>=
0
&&
index
<
this
.
cardlist
.
Count
)
{
cards
.
Add
(
this
.
cardlist
[
index
]);
}
...
...
@@ -1444,11 +1450,11 @@ void SaveAsMSE(bool onlyselect)
if
(
dlg
.
ShowDialog
()
==
DialogResult
.
OK
)
{
bool
isUpdate
=
false
;
#
if
DEBUG
isUpdate
=
MyMsg
.
Question
(
LMSG
.
OnlySet
);
#if DEBUG
isUpdate
=
MyMsg
.
Question
(
LMSG
.
OnlySet
);
#endif
this
.
tasker
.
SetTask
(
MyTask
.
SaveAsMSE
,
cards
,
dlg
.
FileName
,
isUpdate
.
ToString
());
dlg
.
FileName
,
isUpdate
.
ToString
());
this
.
Run
(
LanguageHelper
.
GetMsg
(
LMSG
.
SaveMse
));
}
}
...
...
@@ -1509,7 +1515,7 @@ void ImportImage(string file, string tid)
{
string
f
;
if
(
this
.
pl_image
.
BackgroundImage
!=
null
&&
this
.
pl_image
.
BackgroundImage
!=
this
.
cover
)
&&
this
.
pl_image
.
BackgroundImage
!=
this
.
cover
)
{
//释放图片资源
this
.
pl_image
.
BackgroundImage
.
Dispose
();
this
.
pl_image
.
BackgroundImage
=
this
.
cover
;
...
...
@@ -1543,7 +1549,7 @@ public void SetImage(long id)
if
(
this
.
menuitem_importmseimg
.
Checked
)
//显示MSE图片
{
string
msepic
=
MseMaker
.
GetCardImagePath
(
this
.
tasker
.
MSEImagePath
,
this
.
oldCard
);
if
(
File
.
Exists
(
msepic
))
if
(
File
.
Exists
(
msepic
))
{
this
.
pl_image
.
BackgroundImage
=
MyBitmap
.
ReadImage
(
msepic
);
}
...
...
@@ -1576,7 +1582,7 @@ void Menuitem_convertimageClick(object sender, EventArgs e)
{
bool
isreplace
=
MyMsg
.
Question
(
LMSG
.
IfReplaceExistingImage
);
this
.
tasker
.
SetTask
(
MyTask
.
ConvertImages
,
null
,
fdlg
.
SelectedPath
,
this
.
ygopath
.
gamepath
,
isreplace
.
ToString
());
fdlg
.
SelectedPath
,
this
.
ygopath
.
gamepath
,
isreplace
.
ToString
());
this
.
Run
(
LanguageHelper
.
GetMsg
(
LMSG
.
ConvertImage
));
}
}
...
...
@@ -1605,7 +1611,7 @@ void Menuitem_exportdataClick(object sender, EventArgs e)
this
.
tasker
.
SetTask
(
MyTask
.
ExportData
,
this
.
GetCardList
(
false
),
this
.
ygopath
.
gamepath
,
dlg
.
FileName
,
dlg
.
FileName
,
this
.
GetOpenFile
(),
this
.
Addrequire
);
this
.
Run
(
LanguageHelper
.
GetMsg
(
LMSG
.
ExportData
));
...
...
@@ -1685,7 +1691,7 @@ public void CompareCards(string cdbfile, bool checktext)
//把文件添加到菜单
void
AddMenuItemFormMSE
()
{
if
(!
Directory
.
Exists
(
this
.
datapath
))
if
(!
Directory
.
Exists
(
this
.
datapath
))
{
return
;
}
...
...
@@ -1755,7 +1761,7 @@ private void menuitem_findluafunc_Click(object sender, EventArgs e)
//系列名输入时
void
setCode_InputText
(
int
index
,
ComboBox
cb
,
TextBox
tb
)
{
if
(
index
>=
0
&&
index
<
this
.
setcodeIsedit
.
Length
)
if
(
index
>=
0
&&
index
<
this
.
setcodeIsedit
.
Length
)
{
if
(
this
.
setcodeIsedit
[
index
])
//如果正在编辑
{
...
...
@@ -1854,13 +1860,13 @@ private void menuitem_readmse_Click(object sender, EventArgs e)
{
bool
isUpdate
=
MyMsg
.
Question
(
LMSG
.
IfReplaceExistingImage
);
this
.
tasker
.
SetTask
(
MyTask
.
ReadMSE
,
null
,
dlg
.
FileName
,
isUpdate
.
ToString
());
dlg
.
FileName
,
isUpdate
.
ToString
());
this
.
Run
(
LanguageHelper
.
GetMsg
(
LMSG
.
ReadMSE
));
}
}
}
#
endregion
#
region
压缩数据库
private
void
menuitem_compdb_Click
(
object
sender
,
EventArgs
e
)
{
...
...
@@ -1893,17 +1899,17 @@ private void menuitem_autocheckupdate_Click(object sender, EventArgs e)
this
.
menuitem_autocheckupdate
.
Checked
=
!
this
.
menuitem_autocheckupdate
.
Checked
;
XMLReader
.
Save
(
MyConfig
.
TAG_AUTO_CHECK_UPDATE
,
this
.
menuitem_autocheckupdate
.
Checked
.
ToString
().
ToLower
());
}
//add require automatically
private
void
menuitem_addrequire_Click
(
object
sender
,
EventArgs
e
)
{
//add require automatically
private
void
menuitem_addrequire_Click
(
object
sender
,
EventArgs
e
)
{
this
.
Addrequire
=
Microsoft
.
VisualBasic
.
Interaction
.
InputBox
(
"Module script?\n\nPress \"Cancel\" to remove module script."
,
""
,
this
.
Addrequire
);
this
.
menuitem_addrequire
.
Checked
=
(
this
.
Addrequire
.
Length
>
0
);
XMLReader
.
Save
(
MyConfig
.
TAG_ADD_REQUIRE
,
this
.
Addrequire
);
}
#
endregion
}
#
endregion
#
region
语言菜单
void
GetLanguageItem
()
#
region
语言菜单
void
GetLanguageItem
()
{
if
(!
Directory
.
Exists
(
this
.
datapath
))
{
...
...
@@ -1949,7 +1955,7 @@ void SetLanguage_Click(object sender, EventArgs e)
}
}
#
endregion
//把mse存档导出为图片
void
Menuitem_exportMSEimageClick
(
object
sender
,
EventArgs
e
)
{
...
...
@@ -1959,17 +1965,23 @@ void Menuitem_exportMSEimageClick(object sender, EventArgs e)
}
string
msepath
=
MyPath
.
GetRealPath
(
MyConfig
.
ReadString
(
MyConfig
.
TAG_MSE_PATH
));
if
(!
File
.
Exists
(
msepath
)){
if
(!
File
.
Exists
(
msepath
))
{
MyMsg
.
Error
(
LMSG
.
exportMseImagesErr
);
this
.
menuitem_exportMSEimage
.
Checked
=
false
;
this
.
menuitem_exportMSEimage
.
Checked
=
false
;
return
;
}
else
{
if
(
MseMaker
.
MseIsRunning
()){
}
else
{
if
(
MseMaker
.
MseIsRunning
())
{
MseMaker
.
MseStop
();
this
.
menuitem_exportMSEimage
.
Checked
=
false
;
this
.
menuitem_exportMSEimage
.
Checked
=
false
;
return
;
}
else
{
}
else
{
}
}
//select open mse-set
...
...
@@ -1981,26 +1993,32 @@ void Menuitem_exportMSEimageClick(object sender, EventArgs e)
{
string
mseset
=
dlg
.
FileName
;
string
exportpath
=
MyPath
.
GetRealPath
(
MyConfig
.
ReadString
(
MyConfig
.
TAG_MSE_EXPORT
));
MseMaker
.
ExportSet
(
msepath
,
mseset
,
exportpath
,
delegate
{
this
.
menuitem_exportMSEimage
.
Checked
=
false
;
});
this
.
menuitem_exportMSEimage
.
Checked
=
true
;
}
else
{
this
.
menuitem_exportMSEimage
.
Checked
=
false
;
MseMaker
.
ExportSet
(
msepath
,
mseset
,
exportpath
,
delegate
{
this
.
menuitem_exportMSEimage
.
Checked
=
false
;
});
this
.
menuitem_exportMSEimage
.
Checked
=
true
;
}
else
{
this
.
menuitem_exportMSEimage
.
Checked
=
false
;
}
}
}
void
Menuitem_testPendulumTextClick
(
object
sender
,
EventArgs
e
)
{
Card
c
=
this
.
GetCard
();
if
(
c
!=
null
){
if
(
c
!=
null
)
{
this
.
tasker
.
TestPendulumText
(
c
.
desc
);
}
}
void
Menuitem_export_select_sqlClick
(
object
sender
,
EventArgs
e
)
{
using
(
SaveFileDialog
dlg
=
new
SaveFileDialog
()){
if
(
dlg
.
ShowDialog
()
==
DialogResult
.
OK
){
using
(
SaveFileDialog
dlg
=
new
SaveFileDialog
())
{
if
(
dlg
.
ShowDialog
()
==
DialogResult
.
OK
)
{
DataBase
.
ExportSql
(
dlg
.
FileName
,
this
.
GetCardList
(
true
));
MyMsg
.
Show
(
"OK"
);
}
...
...
@@ -2008,8 +2026,10 @@ void Menuitem_export_select_sqlClick(object sender, EventArgs e)
}
void
Menuitem_export_all_sqlClick
(
object
sender
,
EventArgs
e
)
{
using
(
SaveFileDialog
dlg
=
new
SaveFileDialog
()){
if
(
dlg
.
ShowDialog
()
==
DialogResult
.
OK
){
using
(
SaveFileDialog
dlg
=
new
SaveFileDialog
())
{
if
(
dlg
.
ShowDialog
()
==
DialogResult
.
OK
)
{
DataBase
.
ExportSql
(
dlg
.
FileName
,
this
.
GetCardList
(
false
));
MyMsg
.
Show
(
"OK"
);
}
...
...
@@ -2041,7 +2061,8 @@ void Menuitem_autoreturnClick(object sender, EventArgs e)
int
len
=
MyConfig
.
ReadInteger
(
MyConfig
.
TAG_AUTO_LEN
,
30
);
for
(
int
i
=
0
;
i
<
count
;
i
++)
{
if
(
cards
[
i
].
desc
!=
null
){
if
(
cards
[
i
].
desc
!=
null
)
{
cards
[
i
].
desc
=
StrUtil
.
AutoEnter
(
cards
[
i
].
desc
,
len
,
' '
);
}
}
...
...
@@ -2051,68 +2072,71 @@ void Menuitem_autoreturnClick(object sender, EventArgs e)
}
}
}
void
Menuitem_replaceClick
(
object
sender
,
EventArgs
e
)
{
if
(!
this
.
CheckOpen
())
void
Menuitem_replaceClick
(
object
sender
,
EventArgs
e
)
{
if
(!
this
.
CheckOpen
())
{
return
;
}
using
(
SaveFileDialog
dlg
=
new
SaveFileDialog
())
{
dlg
.
Title
=
LanguageHelper
.
GetMsg
(
LMSG
.
SelectDataBasePath
);
dlg
.
Filter
=
LanguageHelper
.
GetMsg
(
LMSG
.
CdbType
);
if
(
dlg
.
ShowDialog
()
==
DialogResult
.
OK
)
{
Card
[]
cards
=
DataBase
.
Read
(
this
.
nowCdbFile
,
true
,
""
);
int
count
=
cards
.
Length
;
if
(
cards
==
null
||
cards
.
Length
==
0
)
{
dlg
.
Title
=
LanguageHelper
.
GetMsg
(
LMSG
.
SelectDataBasePath
);
dlg
.
Filter
=
LanguageHelper
.
GetMsg
(
LMSG
.
CdbType
);
if
(
dlg
.
ShowDialog
()
==
DialogResult
.
OK
)
{
Card
[]
cards
=
DataBase
.
Read
(
this
.
nowCdbFile
,
true
,
""
);
int
count
=
cards
.
Length
;
if
(
cards
==
null
||
cards
.
Length
==
0
)
{
return
;
}
if
(
DataBase
.
Create
(
dlg
.
FileName
))
{
{
//
_
=
MyConfig
.
ReadInteger
(
MyConfig
.
TAG_AUTO_LEN
,
30
);
for
(
int
i
=
0
;
i
<
count
;
i
++)
{
if
(
cards
[
i
].
desc
!=
null
)
{
cards
[
i
].
desc
=
this
.
tasker
.
MseHelper
.
ReplaceText
(
cards
[
i
].
desc
,
cards
[
i
].
name
);
}
}
DataBase
.
CopyDB
(
dlg
.
FileName
,
false
,
cards
);
MyMsg
.
Show
(
LMSG
.
CopyCardsToDBIsOK
);
}
}
}
}
{
if
(
cards
[
i
].
desc
!=
null
)
{
cards
[
i
].
desc
=
this
.
tasker
.
MseHelper
.
ReplaceText
(
cards
[
i
].
desc
,
cards
[
i
].
name
);
}
}
DataBase
.
CopyDB
(
dlg
.
FileName
,
false
,
cards
);
MyMsg
.
Show
(
LMSG
.
CopyCardsToDBIsOK
);
}
}
}
}
private
void
text2LinkMarks
(
string
text
)
{
try
{
try
{
long
mark
=
Convert
.
ToInt64
(
text
,
2
);
this
.
setLinkMarks
(
mark
,
true
);
}
catch
{
}
catch
{
//
}
}
void
Tb_linkTextChanged
(
object
sender
,
EventArgs
e
)
{
this
.
text2LinkMarks
(
this
.
tb_link
.
Text
);
}
private
void
DataEditForm_KeyDown
(
object
sender
,
KeyEventArgs
e
)
{
if
(
e
.
Control
&&
e
.
KeyCode
==
Keys
.
F
)
{
private
void
DataEditForm_KeyDown
(
object
sender
,
KeyEventArgs
e
)
{
if
(
e
.
Control
&&
e
.
KeyCode
==
Keys
.
F
)
{
this
.
tb_cardname
.
Focus
();
this
.
tb_cardname
.
SelectAll
();
}
}
}
}
private
void
tb_cardtext_KeyDown
(
object
sender
,
KeyEventArgs
e
)
{
...
...
@@ -2138,10 +2162,13 @@ private void menuitem_language_Click(object sender, EventArgs e)
void
Tb_linkKeyPress
(
object
sender
,
KeyPressEventArgs
e
)
{
if
(
e
.
KeyChar
!=
'0'
&&
e
.
KeyChar
!=
'1'
&&
e
.
KeyChar
!=
1
&&
e
.
KeyChar
!=
22
&&
e
.
KeyChar
!=
3
&&
e
.
KeyChar
!=
8
){
// MessageBox.Show("key="+(int)e.KeyChar);
if
(
e
.
KeyChar
!=
'0'
&&
e
.
KeyChar
!=
'1'
&&
e
.
KeyChar
!=
1
&&
e
.
KeyChar
!=
22
&&
e
.
KeyChar
!=
3
&&
e
.
KeyChar
!=
8
)
{
// MessageBox.Show("key="+(int)e.KeyChar);
e
.
Handled
=
true
;
}
else
{
}
else
{
this
.
text2LinkMarks
(
this
.
tb_link
.
Text
);
}
}
...
...
@@ -2152,6 +2179,6 @@ void DataEditFormSizeChanged(object sender, EventArgs e)
this
.
tmpCodes
.
Clear
();
//清空临时的结果
this
.
Search
(
true
);
}
}
}
DataEditorX/Language/LMsg.cs
View file @
44764797
...
...
@@ -5,13 +5,12 @@
* 时间: 10:21
*
*/
using
System
;
namespace
DataEditorX.Language
{
public
enum
LMSG
:
uint
{
titleInfo
=
0
,
titleInfo
=
0
,
titleError
=
0x1
,
titleWarning
=
0x2
,
titleQuestion
=
0x3
,
...
...
@@ -91,9 +90,9 @@ public enum LMSG : uint
ReadMSE
=
0x47
,
ReadMSEisOK
=
0x48
,
PlzRestart
=
0x49
,
exportMseImages
=
0x4a
,
exportMseImagesErr
=
0x4b
,
PlzRestart
=
0x49
,
exportMseImages
=
0x4a
,
exportMseImagesErr
=
0x4b
,
COUNT
,
}
}
DataEditorX/Language/LanguageHelper.cs
View file @
44764797
...
...
@@ -6,10 +6,10 @@
*
*/
using
System
;
using
System.Collections.Generic
;
using
System.Globalization
;
using
System.IO
;
using
System.Text
;
using
System.Globalization
;
using
System.Collections.Generic
;
using
System.Windows.Forms
;
namespace
DataEditorX.Language
...
...
DataEditorX/Language/MyMsg.cs
View file @
44764797
...
...
@@ -5,12 +5,7 @@
* 时间: 7:40
*
*/
using
System
;
using
System.IO
;
using
System.Text
;
using
System.Windows.Forms
;
using
System.Configuration
;
using
System.Collections.Generic
;
namespace
DataEditorX.Language
{
...
...
@@ -19,34 +14,34 @@ namespace DataEditorX.Language
/// </summary>
public
static
class
MyMsg
{
static
readonly
string
info
,
warning
,
error
,
question
;
static
readonly
string
_info
,
_warning
,
_error
,
_
question
;
static
MyMsg
()
{
info
=
LanguageHelper
.
GetMsg
(
LMSG
.
titleInfo
);
warning
=
LanguageHelper
.
GetMsg
(
LMSG
.
titleWarning
);
error
=
LanguageHelper
.
GetMsg
(
LMSG
.
titleError
);
question
=
LanguageHelper
.
GetMsg
(
LMSG
.
titleQuestion
);
_
info
=
LanguageHelper
.
GetMsg
(
LMSG
.
titleInfo
);
_
warning
=
LanguageHelper
.
GetMsg
(
LMSG
.
titleWarning
);
_
error
=
LanguageHelper
.
GetMsg
(
LMSG
.
titleError
);
_
question
=
LanguageHelper
.
GetMsg
(
LMSG
.
titleQuestion
);
}
public
static
void
Show
(
string
strMsg
)
{
MessageBox
.
Show
(
strMsg
,
info
,
MessageBox
.
Show
(
strMsg
,
_
info
,
MessageBoxButtons
.
OK
,
MessageBoxIcon
.
Information
);
}
public
static
void
Warning
(
string
strWarn
)
{
MessageBox
.
Show
(
strWarn
,
warning
,
MessageBox
.
Show
(
strWarn
,
_
warning
,
MessageBoxButtons
.
OK
,
MessageBoxIcon
.
Warning
);
}
public
static
void
Error
(
string
strError
)
{
MessageBox
.
Show
(
strError
,
error
,
MessageBox
.
Show
(
strError
,
_
error
,
MessageBoxButtons
.
OK
,
MessageBoxIcon
.
Error
);
}
public
static
bool
Question
(
string
strQues
)
{
if
(
MessageBox
.
Show
(
strQues
,
question
,
if
(
MessageBox
.
Show
(
strQues
,
_
question
,
MessageBoxButtons
.
OKCancel
,
MessageBoxIcon
.
Question
)
==
DialogResult
.
OK
)
MessageBoxIcon
.
Question
)
==
DialogResult
.
OK
)
{
return
true
;
}
...
...
@@ -57,24 +52,24 @@ public static bool Question(string strQues)
}
public
static
void
Show
(
LMSG
msg
)
{
MessageBox
.
Show
(
LanguageHelper
.
GetMsg
(
msg
),
info
,
MessageBox
.
Show
(
LanguageHelper
.
GetMsg
(
msg
),
_
info
,
MessageBoxButtons
.
OK
,
MessageBoxIcon
.
Information
);
}
public
static
void
Warning
(
LMSG
msg
)
{
MessageBox
.
Show
(
LanguageHelper
.
GetMsg
(
msg
),
warning
,
MessageBox
.
Show
(
LanguageHelper
.
GetMsg
(
msg
),
_
warning
,
MessageBoxButtons
.
OK
,
MessageBoxIcon
.
Warning
);
}
public
static
void
Error
(
LMSG
msg
)
{
MessageBox
.
Show
(
LanguageHelper
.
GetMsg
(
msg
),
error
,
MessageBox
.
Show
(
LanguageHelper
.
GetMsg
(
msg
),
_
error
,
MessageBoxButtons
.
OK
,
MessageBoxIcon
.
Error
);
}
public
static
bool
Question
(
LMSG
msg
)
{
if
(
MessageBox
.
Show
(
LanguageHelper
.
GetMsg
(
msg
),
question
,
if
(
MessageBox
.
Show
(
LanguageHelper
.
GetMsg
(
msg
),
_
question
,
MessageBoxButtons
.
OKCancel
,
MessageBoxIcon
.
Question
)
==
DialogResult
.
OK
)
MessageBoxIcon
.
Question
)
==
DialogResult
.
OK
)
{
return
true
;
}
...
...
DataEditorX/MainForm.cs
View file @
44764797
...
...
@@ -5,18 +5,16 @@
* 时间: 9:19
*
*/
using
DataEditorX.Config
;
using
DataEditorX.Controls
;
using
DataEditorX.Core
;
using
DataEditorX.Language
;
using
System
;
using
System.IO
;
using
System.
Draw
ing
;
using
System.
Thread
ing
;
using
System.Windows.Forms
;
using
WeifenLuo.WinFormsUI.Docking
;
using
DataEditorX.Language
;
using
DataEditorX.Core
;
using
DataEditorX.Config
;
using
DataEditorX.Controls
;
using
System.Threading
;
namespace
DataEditorX
{
public
partial
class
MainForm
:
Form
,
IMainForm
...
...
@@ -106,17 +104,17 @@ void Init()
}
void
InitForm
()
{
LanguageHelper
.
SetFormLabel
(
this
);
//设置所有窗口的语言
DockContentCollection
contents
=
this
.
dockPanel1
.
Contents
;
foreach
(
DockContent
dc
in
contents
)
{
if
(
dc
is
Form
)
{
LanguageHelper
.
SetFormLabel
((
Form
)
dc
);
}
}
LanguageHelper
.
SetFormLabel
(
this
);
//设置所有窗口的语言
DockContentCollection
contents
=
this
.
dockPanel1
.
Contents
;
foreach
(
DockContent
dc
in
contents
)
{
if
(
dc
is
Form
)
{
LanguageHelper
.
SetFormLabel
(
dc
);
}
}
//添加历史菜单
this
.
history
.
MenuHistory
();
...
...
@@ -385,7 +383,7 @@ void Menuitem_newClick(object sender, EventArgs e)
if
(
dlg
.
ShowDialog
()
==
DialogResult
.
OK
)
{
string
file
=
dlg
.
FileName
;
if
(
File
.
Exists
(
file
))
if
(
File
.
Exists
(
file
))
{
File
.
Delete
(
file
);
}
...
...
@@ -536,7 +534,7 @@ private void bgWorker1_DoWork(object sender, System.ComponentModel.DoWorkEventAr
{
this
.
Init
();
}
private
void
bgWorker1_RunWorkerCompleted
(
object
sender
,
System
.
ComponentModel
.
RunWorkerCompletedEventArgs
e
)
{
...
...
@@ -548,7 +546,7 @@ private void bgWorker1_RunWorkerCompleted(object sender, System.ComponentModel.R
private
void
MainForm_Load
(
object
sender
,
EventArgs
e
)
{
//检查更新
if
(
MyConfig
.
ReadBoolean
(
MyConfig
.
TAG_AUTO_CHECK_UPDATE
))
if
(
MyConfig
.
ReadBoolean
(
MyConfig
.
TAG_AUTO_CHECK_UPDATE
))
{
Thread
th
=
new
Thread
(
this
.
CheckUpdate
)
{
...
...
DataEditorX/Program.cs
View file @
44764797
...
...
@@ -5,23 +5,20 @@
* 时间: 12:00
*
*/
using
DataEditorX.Config
;
using
DataEditorX.Language
;
using
System
;
using
System.Configuration
;
using
System.Diagnostics
;
using
System.IO
;
using
System.Reflection
;
using
System.Windows.Forms
;
using
DataEditorX.Config
;
using
DataEditorX.Language
;
namespace
DataEditorX
{
internal
sealed
class
Program
{
[
STAThread
]
private
static
void
Main
(
string
[]
args
)
{
internal
sealed
class
Program
{
[
STAThread
]
private
static
void
Main
(
string
[]
args
)
{
string
arg
=
(
args
.
Length
>
0
)
?
args
[
0
]
:
""
;
if
(
arg
==
MyConfig
.
TAG_SAVE_LAGN
||
arg
==
MyConfig
.
TAG_SAVE_LAGN2
)
{
...
...
@@ -45,8 +42,8 @@ private static void Main(string[] args)
mainForm
.
SetDataPath
(
MyPath
.
Combine
(
Application
.
StartupPath
,
MyConfig
.
TAG_DATA
));
Application
.
Run
(
mainForm
);
}
}
}
}
static
void
SaveLanguage
()
{
string
datapath
=
MyPath
.
Combine
(
Application
.
StartupPath
,
MyConfig
.
TAG_DATA
);
...
...
@@ -62,10 +59,10 @@ static void SaveLanguage()
CodeEditForm
form3
=
new
CodeEditForm
();
LanguageHelper
.
SetFormLabel
(
form3
);
langhelper
.
GetFormLabel
(
form3
);
// LANG.GetFormLabel(this);
// LANG.GetFormLabel(this);
//获取窗体文字
langhelper
.
SaveLanguage
(
conflang
+
".bak"
);
}
}
}
}
DataEditorX/Properties/AssemblyInfo.cs
View file @
44764797
#
region
Using
directives
using
System
;
using
System.Reflection
;
using
System.Runtime.InteropServices
;
...
...
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