Commit 384bf328 authored by mercury233's avatar mercury233

add LiShu style

parent b4e0f075
...@@ -111,7 +111,7 @@ ...@@ -111,7 +111,7 @@
public bool isType(Type typ) public bool isType(Type typ)
{ {
return (type & typ) == typ; return (type & typ) > 0;
} }
} }
} }
......
...@@ -24,13 +24,16 @@ namespace ImgGen ...@@ -24,13 +24,16 @@ namespace ImgGen
private static SQLiteConnection conn; private static SQLiteConnection conn;
private static object locker = new object(); private static object locker = new object();
private static Font nameFont; private static Font nameBlackFont;
private static Font nameWhiteFont;
private static Font numFont; private static Font numFont;
private static Font numUnknownFont; private static Font numUnknownFont;
private static Font txtFont; private static Font txtFont;
private static Font typeFont; private static Font typeFont;
private static Font scaleFontNormal; private static Font scaleFontNormal;
private static Font scaleFontSmall; private static Font scaleFontSmall;
private static SolidBrush nameBlackBrush;
private static SolidBrush nameWhiteBrush;
private static SolidBrush nameShadowBrush; private static SolidBrush nameShadowBrush;
private static SolidBrush pendBgBrush; private static SolidBrush pendBgBrush;
private static SolidBrush textBrush; private static SolidBrush textBrush;
...@@ -40,21 +43,20 @@ namespace ImgGen ...@@ -40,21 +43,20 @@ namespace ImgGen
private static string xyzString = "超量"; private static string xyzString = "超量";
private static string fontName = "文泉驿微米黑"; private static string fontName = "文泉驿微米黑";
private static string fontLiShuName = "方正隶变_GBK";
private static string numfontName = "MatrixBoldSmallCaps"; private static string numfontName = "MatrixBoldSmallCaps";
private static string spfontName = "黑体"; private static string spfontName = "黑体";
private static List<int> zeroStarCards = new List<int>(); private static List<int> zeroStarCards = new List<int>();
private static bool LiShu = false;
public static void InitialDatas(string dbPath) public static void InitialDatas(string dbPath)
{ {
string _xyzString = System.Configuration.ConfigurationManager.AppSettings["XyzString"]; string _xyzString = System.Configuration.ConfigurationManager.AppSettings["XyzString"];
if (_xyzString != null) if (_xyzString != null)
xyzString = _xyzString; xyzString = _xyzString;
string _fontName = System.Configuration.ConfigurationManager.AppSettings["FontName"];
if (_fontName != null)
fontName = _fontName;
string _zeroStarCards = System.Configuration.ConfigurationManager.AppSettings["ZeroStarCards"]; string _zeroStarCards = System.Configuration.ConfigurationManager.AppSettings["ZeroStarCards"];
if (_zeroStarCards != null) if (_zeroStarCards != null)
{ {
...@@ -64,18 +66,37 @@ namespace ImgGen ...@@ -64,18 +66,37 @@ namespace ImgGen
} }
} }
string _style = System.Configuration.ConfigurationManager.AppSettings["Style"];
if (_style == "隶书")
{
LiShu = true;
fontName = fontLiShuName;
}
conn = new SQLiteConnection("Data Source=" + dbPath); conn = new SQLiteConnection("Data Source=" + dbPath);
numFont = new Font(numfontName, 17, FontStyle.Bold, GraphicsUnit.Pixel); numFont = new Font(numfontName, 17, FontStyle.Bold, GraphicsUnit.Pixel);
numUnknownFont = new Font(numfontName, 22, FontStyle.Bold, GraphicsUnit.Pixel); numUnknownFont = new Font(numfontName, 22, FontStyle.Bold, GraphicsUnit.Pixel);
nameFont = new Font(fontName, 28, GraphicsUnit.Pixel); nameBlackFont = new Font(fontName, LiShu ? 30 : 28, LiShu ? FontStyle.Bold : FontStyle.Regular, GraphicsUnit.Pixel);
nameWhiteFont = new Font(fontName, LiShu ? 30 : 28, FontStyle.Regular, GraphicsUnit.Pixel);
typeFont = new Font(fontName, 12, FontStyle.Bold, GraphicsUnit.Pixel); typeFont = new Font(fontName, 12, FontStyle.Bold, GraphicsUnit.Pixel);
txtFont = new Font(fontName, 10, FontStyle.Bold, GraphicsUnit.Pixel); txtFont = new Font(fontName, 10, FontStyle.Bold, GraphicsUnit.Pixel);
scaleFontNormal = new Font(numfontName, 30, GraphicsUnit.Pixel); scaleFontNormal = new Font(numfontName, 30, GraphicsUnit.Pixel);
scaleFontSmall = new Font(numfontName, 27, GraphicsUnit.Pixel); scaleFontSmall = new Font(numfontName, 27, GraphicsUnit.Pixel);
nameShadowBrush = new SolidBrush(Color.FromArgb(64, 64, 0));
pendBgBrush = new SolidBrush(Color.FromArgb(0, 125, 105)); pendBgBrush = new SolidBrush(Color.FromArgb(0, 125, 105));
textBrush = new SolidBrush(Color.FromArgb(0, 0, 0)); textBrush = new SolidBrush(Color.FromArgb(0, 0, 0));
if (LiShu)
{
nameBlackBrush = new SolidBrush(Color.FromArgb(0, 0, 0));
nameWhiteBrush = new SolidBrush(Color.FromArgb(255, 255, 255));
nameShadowBrush = new SolidBrush(Color.FromArgb(0, 0, 0, 0));
}
else
{
nameBlackBrush = new SolidBrush(Color.FromArgb(255, 215, 0));
nameWhiteBrush = new SolidBrush(Color.FromArgb(255, 215, 0));
nameShadowBrush = new SolidBrush(Color.FromArgb(64, 64, 0));
}
justifyFormat = new StringFormat(StringFormat.GenericTypographic); justifyFormat = new StringFormat(StringFormat.GenericTypographic);
justifyFormat.FormatFlags |= StringFormatFlags.MeasureTrailingSpaces; justifyFormat.FormatFlags |= StringFormatFlags.MeasureTrailingSpaces;
...@@ -454,6 +475,8 @@ namespace ImgGen ...@@ -454,6 +475,8 @@ namespace ImgGen
} }
graphics.ScaleTransform(sx1, 1f); graphics.ScaleTransform(sx1, 1f);
graphics.DrawString(str, typeFont, textBrush, 26, 438); graphics.DrawString(str, typeFont, textBrush, 26, 438);
if (LiShu)
graphics.DrawString(str, typeFont, textBrush, 26, 438);
graphics.ResetTransform(); graphics.ResetTransform();
} }
...@@ -484,6 +507,8 @@ namespace ImgGen ...@@ -484,6 +507,8 @@ namespace ImgGen
private static void DrawMonsterEffect(Graphics graphics, string text) private static void DrawMonsterEffect(Graphics graphics, string text)
{ {
DrawJustifiedText(graphics, text, 33, 453, 335, 75); DrawJustifiedText(graphics, text, 33, 453, 335, 75);
if (LiShu)
DrawJustifiedText(graphics, text, 33, 453, 335, 75);
} }
private static void DrawPendulumEffect(Graphics graphics, string desc) private static void DrawPendulumEffect(Graphics graphics, string desc)
...@@ -503,14 +528,17 @@ namespace ImgGen ...@@ -503,14 +528,17 @@ namespace ImgGen
match = regex.Match(desc); match = regex.Match(desc);
if (match.Success) if (match.Success)
mText = match.Groups[match.Groups.Count - 1].Value; mText = match.Groups[match.Groups.Count - 1].Value;
DrawJustifiedText(graphics, pText, 65, 369, 272, 58); DrawJustifiedText(graphics, pText, 65, 369, 272, 58);
if (LiShu)
DrawJustifiedText(graphics, pText, 65, 369, 272, 58);
DrawMonsterEffect(graphics, mText); DrawMonsterEffect(graphics, mText);
} }
private static void DrawSpellTrapEffect(Graphics graphics, string text) private static void DrawSpellTrapEffect(Graphics graphics, string text)
{ {
DrawJustifiedText(graphics, text, 33, 439, 335, 108); DrawJustifiedText(graphics, text, 33, 439, 335, 108);
if (LiShu)
DrawJustifiedText(graphics, text, 33, 439, 335, 108);
} }
private static void DrawSpellTrapType(Graphics graphics, Data data) private static void DrawSpellTrapType(Graphics graphics, Data data)
...@@ -555,18 +583,26 @@ namespace ImgGen ...@@ -555,18 +583,26 @@ namespace ImgGen
graphics.DrawImage(bLinkMarkers[8], 329, 91, 37, 37); graphics.DrawImage(bLinkMarkers[8], 329, 91, 37, 37);
} }
private static void DrawName(Graphics graphics, string name) private static void DrawName(Graphics graphics, string name, Data data)
{ {
float width = graphics.MeasureString(name, nameFont).Width; Font nameFont = nameBlackFont;
Brush nameBrush = nameBlackBrush;
if (data.isType(Type.TYPE_SPELL | Type.TYPE_TRAP | Type.TYPE_FUSION | Type.TYPE_XYZ | Type.TYPE_LINK))
{
nameFont = nameWhiteFont;
nameBrush = nameWhiteBrush;
}
SizeF size = graphics.MeasureString(name, nameFont);
float width = size.Width;
float sx = 1f; float sx = 1f;
if (width > 310f) if (width > 308f)
{ {
sx *= 310f / width; sx *= 308f / width;
} }
graphics.TranslateTransform(26, 28); graphics.TranslateTransform(27, LiShu ? 29.5f : 28.5f);
graphics.ScaleTransform(sx, 1f); graphics.ScaleTransform(sx, 1f);
graphics.DrawString(name, nameFont, nameShadowBrush, 0f, 0f); graphics.DrawString(name, nameFont, nameShadowBrush, 0f, 0f);
graphics.DrawString(name, nameFont, Brushes.Gold, 1f, 1f); graphics.DrawString(name, nameFont, nameBrush, 1f, 1f);
graphics.ResetTransform(); graphics.ResetTransform();
} }
...@@ -587,7 +623,7 @@ namespace ImgGen ...@@ -587,7 +623,7 @@ namespace ImgGen
DrawPicture(graphics, data); DrawPicture(graphics, data);
DrawTemplate(graphics, data); DrawTemplate(graphics, data);
DrawName(graphics, name); DrawName(graphics, name, data);
if (data.isType(Type.TYPE_MONSTER)) if (data.isType(Type.TYPE_MONSTER))
{ {
...@@ -697,21 +733,30 @@ namespace ImgGen ...@@ -697,21 +733,30 @@ namespace ImgGen
string word = line.Substring(pos, 1); string word = line.Substring(pos, 1);
string nextword = GetNextWord(line, pos); string nextword = GetNextWord(line, pos);
if (word == "●") if (word == "●" && !LiShu)
{ {
Font spFont = new Font(spfontName, size * 0.9f, txtFont.Style, txtFont.Unit); Font spFont = new Font(spfontName, size * 0.9f, txtFont.Style, txtFont.Unit);
graphics.DrawString(word, spFont, textBrush, dx + (size / 10f), dy + (size / 10f), justifyFormat); graphics.DrawString(word, spFont, textBrush, dx + (size / 10f), dy + (size / 10f), justifyFormat);
} }
else if (word == "×") else if (word == "×" && !LiShu)
{ {
Font spFont = new Font(spfontName, size, txtFont.Style, txtFont.Unit); Font spFont = new Font(spfontName, size, txtFont.Style, txtFont.Unit);
graphics.DrawString(word, spFont, textBrush, dx + (size / 3f), dy + (size / 20f), justifyFormat); graphics.DrawString(word, spFont, textBrush, dx + (size / 3f), dy + (size / 20f), justifyFormat);
} }
else if (word == "量") else if (word == "量" && !LiShu)
{ {
Font spFont = new Font(spfontName, size, txtFont.Style, txtFont.Unit); Font spFont = new Font(spfontName, size, txtFont.Style, txtFont.Unit);
graphics.DrawString(word, spFont, textBrush, dx, dy + (size / 20f), justifyFormat); graphics.DrawString(word, spFont, textBrush, dx, dy + (size / 20f), justifyFormat);
} }
else if (word[0] >= '\xff10' && word[0] <= '\xff19' && LiShu) // 0-9数字
{
graphics.DrawString(word, font, textBrush, dx, dy - (size / 8f), justifyFormat);
}
else if (word[0] >= '\x2460' && word[0] <= '\x2469' && LiShu) // ①-⑩数字
{
Font spFont = new Font(fontName, size * 0.8f, txtFont.Style, txtFont.Unit);
graphics.DrawString(word, spFont, textBrush, dx + (size / 10f), dy + (size / 10f), justifyFormat);
}
else else
graphics.DrawString(word, font, textBrush, dx, dy, justifyFormat); graphics.DrawString(word, font, textBrush, dx, dy, justifyFormat);
......
...@@ -4,8 +4,8 @@ ...@@ -4,8 +4,8 @@
<supportedRuntime version="v2.0.50727"/> <supportedRuntime version="v2.0.50727"/>
</startup> </startup>
<appSettings> <appSettings>
<add key="Style" value="隶书" />
<add key="XyzString" value="超量" /> <add key="XyzString" value="超量" />
<add key="FontName" value="文泉驿微米黑" />
<add key="ZeroStarCards" value="1686814,26973555,43490025,52653092,65305468,90884403" /> <add key="ZeroStarCards" value="1686814,26973555,43490025,52653092,65305468,90884403" />
<add key="GenerateLarge" value="True" /> <add key="GenerateLarge" value="True" />
<add key="GenerateSmall" value="false" /> <add key="GenerateSmall" value="false" />
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment