Uses Regex to determine if it's in a foreign language

If it is we assume it's Japanese because I'm an American or something.
This commit is contained in:
ZestyTS 2022-07-31 13:11:34 -07:00
parent a451450d4f
commit 04150a5a3d

View file

@ -3,6 +3,7 @@ using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Text;
using System.Linq;
using System.Text.RegularExpressions;
namespace UWUVCI_AIO_WPF.Classes
{
@ -136,8 +137,16 @@ namespace UWUVCI_AIO_WPF.Classes
if (Frame != null)
g.DrawImage(Frame, new Rectangle(0, 0, 1280, 720));
if (NameLine1 != null && NameLine2 != null)
var isNotEnglish = false;
if (!string.IsNullOrEmpty(NameLine1) || !string.IsNullOrEmpty(NameLine2))
{
var regex= "^[a-zA-Z0-9\\d\\s\\.\\'\\&\\\\(\\)\\-\\:\\;\\.\\,\\?\\^\\¿]*$";
var match = Regex.Match(NameLine1, regex);
var match2 = Regex.Match(NameLine2, regex);
if (!match.Success || !match2.Success)
isNotEnglish = true;
Pen outlineBold = new Pen(Color.FromArgb(222, 222, 222), 5.0F);
Pen shadowBold = new Pen(Color.FromArgb(190, 190, 190), 7.0F);
Rectangle rectangleNL1 = Longname ? new Rectangle(578, 313, 640, 50) : new Rectangle(578, 340, 640, 50);
@ -171,10 +180,16 @@ namespace UWUVCI_AIO_WPF.Classes
}
}
if (Released > 0)
{
GraphicsPath r = new GraphicsPath();
r.AddString("Released: " + Released.ToString(), font.FontFamily,
var releasedString = "Released: " + Released.ToString();
if (isNotEnglish)
releasedString = Released.ToString() + "年発売";
r.AddString(releasedString, font.FontFamily,
(int)(FontStyle.Regular),
g.DpiY * 25.0F / 72.0F, new Rectangle(586, 450, 600, 40), format);
g.DrawPath(shadow, r);
@ -185,9 +200,15 @@ namespace UWUVCI_AIO_WPF.Classes
if (Players > 0)
{
string pStr = Players >= 4 ? "1-4" : (Players == 1 ? "1" : "1-" + Players.ToString());
if (isNotEnglish)
pStr = "プレイ人数 " + pStr + "人";
else
pStr = "Players: " + pStr;
GraphicsPath p = new GraphicsPath();
p.AddString("Players: " + pStr, font.FontFamily,
p.AddString(pStr, font.FontFamily,
(int)(FontStyle.Regular),
g.DpiY * 25.0F / 72.0F, new Rectangle(586, 496, 600, 40), format);