auto resize qDescription + translated reload time + save locres

This commit is contained in:
Asval
2019-06-19 23:46:46 +02:00
parent 3a1b11102a
commit 1538dbb45c
6 changed files with 125 additions and 4 deletions

View File

@@ -349,11 +349,33 @@ namespace FModel
Image reload = Resources.reload64;
myGraphic.DrawImage(ImageUtilities.ResizeImage(reload, 15, 15), new Point(50 + (statParsed.ClipSize.ToString().Length * 7) + 47, 500)); //50=clipsize text position | for each clipsize letter we add 7 to x | 47=difference between 2 icons
myGraphic.DrawString(statParsed.ReloadTime + " seconds", new Font(FontUtilities.pfc.Families[0], 13), new SolidBrush(Color.White), new Point(64 + (statParsed.ClipSize.ToString().Length * 7) + 47, 500)); //64=50+icon size (-1 because that wasn't perfectly at the position i wanted)
myGraphic.DrawString(statParsed.ReloadTime + getSecondsWithLanguage(), new Font(FontUtilities.pfc.Families[0], 13), new SolidBrush(Color.White), new Point(64 + (statParsed.ClipSize.ToString().Length * 7) + 47, 500)); //64=50+icon size (-1 because that wasn't perfectly at the position i wanted)
DrawToRight(weaponName, myGraphic);
}
}
/// <summary>
/// manual translation to improve speed and in case the key is deleted
/// that's just 1 word so /shrug
/// </summary>
/// <returns></returns>
private static string getSecondsWithLanguage()
{
switch (Settings.Default.IconLanguage)
{
case "French":
return " secondes";
case "German":
return " Sekunden";
case "Italian":
return " secondi";
case "Spanish":
case "Spanish (LA)":
return " segundos";
default:
return " seconds";
}
}
/// <summary>
/// this is only triggered for heroes and defenders

View File

@@ -40,5 +40,28 @@ namespace FModel
centeredStringLine.LineAlignment = StringAlignment.Center;
centeredStringLine.Alignment = StringAlignment.Center;
}
/// <summary>
/// https://stackoverflow.com/questions/19674743/dynamically-resizing-font-to-fit-space-while-using-graphics-drawstring/19674954
/// </summary>
/// <param name="g"></param>
/// <param name="longString"></param>
/// <param name="Room"></param>
/// <param name="PreferedFont"></param>
/// <returns></returns>
public static Font FindFont(Graphics g, string longString, Size Room, Font PreferedFont)
{
SizeF RealSize = g.MeasureString(longString, PreferedFont);
float HeightScaleRatio = Room.Height / RealSize.Height;
float WidthScaleRatio = Room.Width / RealSize.Width;
float ScaleRatio = (HeightScaleRatio < WidthScaleRatio)
? ScaleRatio = HeightScaleRatio
: ScaleRatio = WidthScaleRatio;
float ScaleFontSize = PreferedFont.Size * ScaleRatio;
return new Font(PreferedFont.FontFamily, ScaleFontSize);
}
}
}

View File

@@ -30,6 +30,7 @@ namespace FModel
Directory.CreateDirectory(App.DefaultOutputPath + "\\Extracted\\");
Directory.CreateDirectory(App.DefaultOutputPath + "\\Icons\\");
Directory.CreateDirectory(App.DefaultOutputPath + "\\Sounds\\");
Directory.CreateDirectory(App.DefaultOutputPath + "\\LocRes\\");
}
/// <summary>