Commit 0b6abd4a authored by mercury233's avatar mercury233

update app settings, add support for zero star cards

parent 2a45df21
...@@ -35,7 +35,10 @@ namespace ImgGen ...@@ -35,7 +35,10 @@ namespace ImgGen
private static string regex_monster = @"[果|介|述|報]】\n([\S\s]*)"; private static string regex_monster = @"[果|介|述|報]】\n([\S\s]*)";
private static string regex_pendulum = @"】[\s\S]*?\n([\S\s]*?)\n【"; private static string regex_pendulum = @"】[\s\S]*?\n([\S\s]*?)\n【";
private static string xyzString;
private static string xyzString = "超量";
private static string fontName = "文泉驿微米黑";
private static List<int> zeroStarCards = new List<int>();
public static Bitmap GetImage(int code) public static Bitmap GetImage(int code)
{ {
...@@ -129,17 +132,33 @@ namespace ImgGen ...@@ -129,17 +132,33 @@ namespace ImgGen
return ""; return "";
} }
public static void InitialDatas(string dbPath = "../cards.cdb", string xyz = "超量") public static void InitialDatas(string dbPath)
{ {
xyzString = xyz; string _xyzString = System.Configuration.ConfigurationManager.AppSettings["XyzString"];
if (_xyzString != null)
xyzString = _xyzString;
string _fontName = System.Configuration.ConfigurationManager.AppSettings["FontName"];
if (_fontName != null)
fontName = _fontName;
string _zeroStarCards = System.Configuration.ConfigurationManager.AppSettings["ZeroStarCards"];
if (_zeroStarCards != null)
{
foreach (string i in _zeroStarCards.Split(','))
{
zeroStarCards.Add(int.Parse(i));
}
}
conn = new SQLiteConnection("Data Source=" + dbPath); conn = new SQLiteConnection("Data Source=" + dbPath);
numFont = new Font("文泉驿微米黑", 12, FontStyle.Regular, GraphicsUnit.Pixel); numFont = new Font(fontName, 12, FontStyle.Regular, GraphicsUnit.Pixel);
linkFont = new Font("文泉驿微米黑", 12, FontStyle.Bold, GraphicsUnit.Pixel); linkFont = new Font(fontName, 12, FontStyle.Bold, GraphicsUnit.Pixel);
nameFont = new Font("文泉驿微米黑", 24, GraphicsUnit.Pixel); nameFont = new Font(fontName, 24, GraphicsUnit.Pixel);
typeFont = new Font("文泉驿微米黑", 12, FontStyle.Regular, GraphicsUnit.Pixel); typeFont = new Font(fontName, 12, FontStyle.Regular, GraphicsUnit.Pixel);
txtFont = new Font("文泉驿微米黑", 10, GraphicsUnit.Pixel); txtFont = new Font(fontName, 10, GraphicsUnit.Pixel);
scaleFontNormal = new Font("文泉驿微米黑", 24, GraphicsUnit.Pixel); scaleFontNormal = new Font(fontName, 24, GraphicsUnit.Pixel);
scaleFontSmall = new Font("文泉驿微米黑", 20, GraphicsUnit.Pixel); scaleFontSmall = new Font(fontName, 20, GraphicsUnit.Pixel);
bTemplates[0] = new Bitmap("./textures/card_spell.png"); bTemplates[0] = new Bitmap("./textures/card_spell.png");
bTemplates[1] = new Bitmap("./textures/card_trap.png"); bTemplates[1] = new Bitmap("./textures/card_trap.png");
bTemplates[2] = new Bitmap("./textures/card_synchro.png"); bTemplates[2] = new Bitmap("./textures/card_synchro.png");
...@@ -312,19 +331,22 @@ namespace ImgGen ...@@ -312,19 +331,22 @@ namespace ImgGen
text.text = GetStandardText(text.text); text.text = GetStandardText(text.text);
if (data.isType(Type.TYPE_MONSTER)) if (data.isType(Type.TYPE_MONSTER))
{ {
int nStar; if (!zeroStarCards.Contains(data.code))
if (data.isType(Type.TYPE_XYZ))
{ {
for (nStar = 0; nStar < (data.level & 0xff); nStar++) int nStar;
if (data.isType(Type.TYPE_XYZ))
{ {
graphics.DrawImage(bStar[1], (int)35 + (22.5f * nStar), 60, 20, 20); for (nStar = 0; nStar < (data.level & 0xff); nStar++)
{
graphics.DrawImage(bStar[1], (int)35 + (22.5f * nStar), 60, 20, 20);
}
} }
} else if (!data.isType(Type.TYPE_LINK))
else if (!data.isType(Type.TYPE_LINK))
{
for (nStar = 0; nStar < (data.level & 0xff); nStar++)
{ {
graphics.DrawImage(bStar[0], (int)282 - (22.5f * nStar), 60, 20, 20); for (nStar = 0; nStar < (data.level & 0xff); nStar++)
{
graphics.DrawImage(bStar[0], (int)282 - (22.5f * nStar), 60, 20, 20);
}
} }
} }
......
...@@ -38,6 +38,7 @@ ...@@ -38,6 +38,7 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.configuration" />
<Reference Include="System.Data" /> <Reference Include="System.Data" />
<Reference Include="System.Data.SQLite"> <Reference Include="System.Data.SQLite">
<HintPath>.\System.Data.SQLite.dll</HintPath> <HintPath>.\System.Data.SQLite.dll</HintPath>
......
...@@ -22,17 +22,13 @@ ...@@ -22,17 +22,13 @@
private static void Main(string[] args) private static void Main(string[] args)
{ {
if (args.Length > 1) if (args.Length > 0)
{
DataManager.InitialDatas(args[0], args[1]);
}
else if (args.Length > 0)
{ {
DataManager.InitialDatas(args[0]); DataManager.InitialDatas(args[0]);
} }
else else
{ {
DataManager.InitialDatas(); DataManager.InitialDatas("../cards.cdb");
} }
Encoder quality = Encoder.Quality; Encoder quality = Encoder.Quality;
ImageCodecInfo encoderInfo = GetEncoderInfo("image/jpeg"); ImageCodecInfo encoderInfo = GetEncoderInfo("image/jpeg");
...@@ -40,17 +36,27 @@ ...@@ -40,17 +36,27 @@
EncoderParameter parameter = new EncoderParameter(quality, 95L); EncoderParameter parameter = new EncoderParameter(quality, 95L);
encoderParams.Param[0] = parameter; encoderParams.Param[0] = parameter;
string[] files = Directory.GetFiles("./pico", "*.jpg"); string[] files = Directory.GetFiles("./pico", "*.jpg");
Directory.CreateDirectory("./picn"); bool generateLarge = System.Configuration.ConfigurationManager.AppSettings["GenerateLarge"] == "False" ? false : true; // true if AppSettings null
Directory.CreateDirectory("./pics"); bool generateSmall = System.Configuration.ConfigurationManager.AppSettings["GenerateSmall"] == "True" ? true : false;
bool generateThumb = System.Configuration.ConfigurationManager.AppSettings["GenerateThumb"] == "True" ? true : false;
if (generateLarge)
Directory.CreateDirectory("./picn");
if (generateSmall)
Directory.CreateDirectory("./pics");
if (generateThumb)
Directory.CreateDirectory("./pics/thumbnail");
foreach (string str in files) foreach (string str in files)
{ {
int code = int.Parse(Path.GetFileNameWithoutExtension(str)); int code = int.Parse(Path.GetFileNameWithoutExtension(str));
string fileName = Path.GetFileName(str); string fileName = Path.GetFileName(str);
Console.WriteLine("Generating {0}", fileName); Console.WriteLine("Generating {0}", fileName);
Bitmap image = DataManager.GetImage(code); Bitmap image = DataManager.GetImage(code);
image.Save("./picn/" + fileName, encoderInfo, encoderParams); if (generateLarge)
DataManager.Zoom(image, 177, 254).Save("./pics/" + fileName, encoderInfo, encoderParams); image.Save("./picn/" + fileName, encoderInfo, encoderParams);
//DataManager.Zoom(image, 44, 64).Save("./pics/thumbnail/" + fileName, encoderInfo, encoderParams); if (generateSmall)
DataManager.Zoom(image, 177, 254).Save("./pics/" + fileName, encoderInfo, encoderParams);
if (generateThumb)
DataManager.Zoom(image, 44, 64).Save("./pics/thumbnail/" + fileName, encoderInfo, encoderParams);
image.Dispose(); image.Dispose();
} }
} }
......
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<configuration> <configuration>
<startup><supportedRuntime version="v2.0.50727"/></startup></configuration> <startup>
<supportedRuntime version="v2.0.50727"/>
</startup>
<appSettings>
<add key="XyzString" value="超量" />
<add key="FontName" value="文泉驿微米黑" />
<add key="ZeroStarCards" value="1686814,43490025,52653092,65305468,90884403" />
<add key="GenerateLarge" value="True" />
<add key="GenerateSmall" value="True" />
<add key="GenerateThumb" value="False" />
</appSettings>
</configuration>
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