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