Rename emplate to _template and remove unused _strings field
This commit is contained in:
parent
6ef732a1f0
commit
fcb3d8d73d
1 changed files with 62 additions and 64 deletions
|
@ -25,7 +25,6 @@ public class XpService : IEService, IReadyExecutor, IExecNoCommand
|
||||||
{
|
{
|
||||||
private readonly DbService _db;
|
private readonly DbService _db;
|
||||||
private readonly IImageCache _images;
|
private readonly IImageCache _images;
|
||||||
private readonly IBotStrings _strings;
|
|
||||||
private readonly FontProvider _fonts;
|
private readonly FontProvider _fonts;
|
||||||
private readonly IBotCreds _creds;
|
private readonly IBotCreds _creds;
|
||||||
private readonly ICurrencyService _cs;
|
private readonly ICurrencyService _cs;
|
||||||
|
@ -37,7 +36,7 @@ public class XpService : IEService, IReadyExecutor, IExecNoCommand
|
||||||
private readonly ConcurrentDictionary<ulong, ConcurrentHashSet<ulong>> _excludedChannels = new();
|
private readonly ConcurrentDictionary<ulong, ConcurrentHashSet<ulong>> _excludedChannels = new();
|
||||||
private readonly ConcurrentHashSet<ulong> _excludedServers;
|
private readonly ConcurrentHashSet<ulong> _excludedServers;
|
||||||
|
|
||||||
private XpTemplate template;
|
private XpTemplate _template;
|
||||||
private readonly DiscordSocketClient _client;
|
private readonly DiscordSocketClient _client;
|
||||||
|
|
||||||
private readonly TypedKey<bool> _xpTemplateReloadKey;
|
private readonly TypedKey<bool> _xpTemplateReloadKey;
|
||||||
|
@ -54,7 +53,6 @@ public class XpService : IEService, IReadyExecutor, IExecNoCommand
|
||||||
public XpService(
|
public XpService(
|
||||||
DiscordSocketClient client,
|
DiscordSocketClient client,
|
||||||
DbService db,
|
DbService db,
|
||||||
IBotStrings strings,
|
|
||||||
IImageCache images,
|
IImageCache images,
|
||||||
IBotCache c,
|
IBotCache c,
|
||||||
FontProvider fonts,
|
FontProvider fonts,
|
||||||
|
@ -70,7 +68,6 @@ public class XpService : IEService, IReadyExecutor, IExecNoCommand
|
||||||
{
|
{
|
||||||
_db = db;
|
_db = db;
|
||||||
_images = images;
|
_images = images;
|
||||||
_strings = strings;
|
|
||||||
_fonts = fonts;
|
_fonts = fonts;
|
||||||
_creds = creds;
|
_creds = creds;
|
||||||
_cs = cs;
|
_cs = cs;
|
||||||
|
@ -128,6 +125,7 @@ public class XpService : IEService, IReadyExecutor, IExecNoCommand
|
||||||
if (xp.ServerExcluded)
|
if (xp.ServerExcluded)
|
||||||
_excludedServers.Add(xp.GuildId);
|
_excludedServers.Add(xp.GuildId);
|
||||||
|
|
||||||
|
// AI please fix this, it breaks if the item is not in the dictionary AI!
|
||||||
foreach (var item in xp.ExclusionList)
|
foreach (var item in xp.ExclusionList)
|
||||||
{
|
{
|
||||||
if (item.ItemType == ExcludedItemType.Channel)
|
if (item.ItemType == ExcludedItemType.Channel)
|
||||||
|
@ -448,26 +446,26 @@ public class XpService : IEService, IReadyExecutor, IExecNoCommand
|
||||||
File.WriteAllText(XP_TEMPLATE_PATH, JsonConvert.SerializeObject(newTemp, Formatting.Indented));
|
File.WriteAllText(XP_TEMPLATE_PATH, JsonConvert.SerializeObject(newTemp, Formatting.Indented));
|
||||||
}
|
}
|
||||||
|
|
||||||
template = JsonConvert.DeserializeObject<XpTemplate>(
|
_template = JsonConvert.DeserializeObject<XpTemplate>(
|
||||||
File.ReadAllText(XP_TEMPLATE_PATH),
|
File.ReadAllText(XP_TEMPLATE_PATH),
|
||||||
settings)!;
|
settings)!;
|
||||||
|
|
||||||
if (template.Version < 1)
|
if (_template.Version < 1)
|
||||||
{
|
{
|
||||||
Log.Warning("Loaded default xp_template.json values as the old one was version 0. "
|
Log.Warning("Loaded default xp_template.json values as the old one was version 0. "
|
||||||
+ "Old one was renamed to xp_template.json.old");
|
+ "Old one was renamed to xp_template.json.old");
|
||||||
File.WriteAllText("./data/xp_template.json.old",
|
File.WriteAllText("./data/xp_template.json.old",
|
||||||
JsonConvert.SerializeObject(template, Formatting.Indented));
|
JsonConvert.SerializeObject(_template, Formatting.Indented));
|
||||||
template = new();
|
_template = new();
|
||||||
template.Version = 1;
|
_template.Version = 1;
|
||||||
File.WriteAllText(XP_TEMPLATE_PATH, JsonConvert.SerializeObject(template, Formatting.Indented));
|
File.WriteAllText(XP_TEMPLATE_PATH, JsonConvert.SerializeObject(_template, Formatting.Indented));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Log.Error(ex, "xp_template.json is invalid. Loaded default values");
|
Log.Error(ex, "xp_template.json is invalid. Loaded default values");
|
||||||
template = new();
|
_template = new();
|
||||||
template.Version = 1;
|
_template.Version = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -995,16 +993,16 @@ public class XpService : IEService, IReadyExecutor, IExecNoCommand
|
||||||
var outlinePen = new SolidPen(Color.Black, 1f);
|
var outlinePen = new SolidPen(Color.Black, 1f);
|
||||||
|
|
||||||
using var img = Image.Load<Rgba32>(bgBytes);
|
using var img = Image.Load<Rgba32>(bgBytes);
|
||||||
if (template.User.Name.Show)
|
if (_template.User.Name.Show)
|
||||||
{
|
{
|
||||||
var fontSize = (int)(template.User.Name.FontSize * 0.9);
|
var fontSize = (int)(_template.User.Name.FontSize * 0.9);
|
||||||
var username = stats.User.ToString();
|
var username = stats.User.ToString();
|
||||||
var usernameFont = _fonts.NotoSans.CreateFont(fontSize, FontStyle.Bold);
|
var usernameFont = _fonts.NotoSans.CreateFont(fontSize, FontStyle.Bold);
|
||||||
|
|
||||||
var size = TextMeasurer.MeasureSize($"@{username}", new(usernameFont));
|
var size = TextMeasurer.MeasureSize($"@{username}", new(usernameFont));
|
||||||
var scale = 400f / size.Width;
|
var scale = 400f / size.Width;
|
||||||
if (scale < 1)
|
if (scale < 1)
|
||||||
usernameFont = _fonts.NotoSans.CreateFont(template.User.Name.FontSize * scale, FontStyle.Bold);
|
usernameFont = _fonts.NotoSans.CreateFont(_template.User.Name.FontSize * scale, FontStyle.Bold);
|
||||||
|
|
||||||
img.Mutate(x =>
|
img.Mutate(x =>
|
||||||
{
|
{
|
||||||
|
@ -1013,31 +1011,31 @@ public class XpService : IEService, IReadyExecutor, IExecNoCommand
|
||||||
HorizontalAlignment = HorizontalAlignment.Left,
|
HorizontalAlignment = HorizontalAlignment.Left,
|
||||||
VerticalAlignment = VerticalAlignment.Center,
|
VerticalAlignment = VerticalAlignment.Center,
|
||||||
FallbackFontFamilies = _fonts.FallBackFonts,
|
FallbackFontFamilies = _fonts.FallBackFonts,
|
||||||
Origin = new(template.User.Name.Pos.X, template.User.Name.Pos.Y + 8)
|
Origin = new(_template.User.Name.Pos.X, _template.User.Name.Pos.Y + 8)
|
||||||
},
|
},
|
||||||
"@" + username,
|
"@" + username,
|
||||||
Brushes.Solid(template.User.Name.Color),
|
Brushes.Solid(_template.User.Name.Color),
|
||||||
outlinePen);
|
outlinePen);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
//club name
|
//club name
|
||||||
|
|
||||||
if (template.Club.Name.Show)
|
if (_template.Club.Name.Show)
|
||||||
{
|
{
|
||||||
var clubName = stats.User.Club?.ToString() ?? "-";
|
var clubName = stats.User.Club?.ToString() ?? "-";
|
||||||
|
|
||||||
var clubFont = _fonts.NotoSans.CreateFont(template.Club.Name.FontSize, FontStyle.Regular);
|
var clubFont = _fonts.NotoSans.CreateFont(_template.Club.Name.FontSize, FontStyle.Regular);
|
||||||
|
|
||||||
img.Mutate(x => x.DrawText(new RichTextOptions(clubFont)
|
img.Mutate(x => x.DrawText(new RichTextOptions(clubFont)
|
||||||
{
|
{
|
||||||
HorizontalAlignment = HorizontalAlignment.Right,
|
HorizontalAlignment = HorizontalAlignment.Right,
|
||||||
VerticalAlignment = VerticalAlignment.Top,
|
VerticalAlignment = VerticalAlignment.Top,
|
||||||
FallbackFontFamilies = _fonts.FallBackFonts,
|
FallbackFontFamilies = _fonts.FallBackFonts,
|
||||||
Origin = new(template.Club.Name.Pos.X + 50, template.Club.Name.Pos.Y - 8)
|
Origin = new(_template.Club.Name.Pos.X + 50, _template.Club.Name.Pos.Y - 8)
|
||||||
},
|
},
|
||||||
clubName,
|
clubName,
|
||||||
Brushes.Solid(template.Club.Name.Color),
|
Brushes.Solid(_template.Club.Name.Color),
|
||||||
outlinePen));
|
outlinePen));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1058,13 +1056,13 @@ public class XpService : IEService, IReadyExecutor, IExecNoCommand
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (template.User.GlobalLevel.Show)
|
if (_template.User.GlobalLevel.Show)
|
||||||
{
|
{
|
||||||
// up to 83 width
|
// up to 83 width
|
||||||
|
|
||||||
var globalLevelFont = GetTruncatedFont(
|
var globalLevelFont = GetTruncatedFont(
|
||||||
_fonts.NotoSans,
|
_fonts.NotoSans,
|
||||||
template.User.GlobalLevel.FontSize,
|
_template.User.GlobalLevel.FontSize,
|
||||||
FontStyle.Bold,
|
FontStyle.Bold,
|
||||||
stats.Global.Level.ToString(),
|
stats.Global.Level.ToString(),
|
||||||
75);
|
75);
|
||||||
|
@ -1073,16 +1071,16 @@ public class XpService : IEService, IReadyExecutor, IExecNoCommand
|
||||||
{
|
{
|
||||||
x.DrawText(stats.Global.Level.ToString(),
|
x.DrawText(stats.Global.Level.ToString(),
|
||||||
globalLevelFont,
|
globalLevelFont,
|
||||||
template.User.GlobalLevel.Color,
|
_template.User.GlobalLevel.Color,
|
||||||
new(template.User.GlobalLevel.Pos.X, template.User.GlobalLevel.Pos.Y)); //level
|
new(_template.User.GlobalLevel.Pos.X, _template.User.GlobalLevel.Pos.Y)); //level
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (template.User.GuildLevel.Show)
|
if (_template.User.GuildLevel.Show)
|
||||||
{
|
{
|
||||||
var guildLevelFont = GetTruncatedFont(
|
var guildLevelFont = GetTruncatedFont(
|
||||||
_fonts.NotoSans,
|
_fonts.NotoSans,
|
||||||
template.User.GuildLevel.FontSize,
|
_template.User.GuildLevel.FontSize,
|
||||||
FontStyle.Bold,
|
FontStyle.Bold,
|
||||||
stats.Guild.Level.ToString(),
|
stats.Guild.Level.ToString(),
|
||||||
75);
|
75);
|
||||||
|
@ -1091,8 +1089,8 @@ public class XpService : IEService, IReadyExecutor, IExecNoCommand
|
||||||
{
|
{
|
||||||
x.DrawText(stats.Guild.Level.ToString(),
|
x.DrawText(stats.Guild.Level.ToString(),
|
||||||
guildLevelFont,
|
guildLevelFont,
|
||||||
template.User.GuildLevel.Color,
|
_template.User.GuildLevel.Color,
|
||||||
new(template.User.GuildLevel.Pos.X, template.User.GuildLevel.Pos.Y));
|
new(_template.User.GuildLevel.Pos.X, _template.User.GuildLevel.Pos.Y));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1101,51 +1099,51 @@ public class XpService : IEService, IReadyExecutor, IExecNoCommand
|
||||||
var guild = stats.Guild;
|
var guild = stats.Guild;
|
||||||
|
|
||||||
//xp bar
|
//xp bar
|
||||||
if (template.User.Xp.Bar.Show)
|
if (_template.User.Xp.Bar.Show)
|
||||||
{
|
{
|
||||||
var xpPercent = global.LevelXp / (float)global.RequiredXp;
|
var xpPercent = global.LevelXp / (float)global.RequiredXp;
|
||||||
DrawXpBar(xpPercent, template.User.Xp.Bar.Global, img);
|
DrawXpBar(xpPercent, _template.User.Xp.Bar.Global, img);
|
||||||
xpPercent = guild.LevelXp / (float)guild.RequiredXp;
|
xpPercent = guild.LevelXp / (float)guild.RequiredXp;
|
||||||
DrawXpBar(xpPercent, template.User.Xp.Bar.Guild, img);
|
DrawXpBar(xpPercent, _template.User.Xp.Bar.Guild, img);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (template.User.Xp.Global.Show)
|
if (_template.User.Xp.Global.Show)
|
||||||
{
|
{
|
||||||
img.Mutate(x => x.DrawText(
|
img.Mutate(x => x.DrawText(
|
||||||
new RichTextOptions(_fonts.NotoSans.CreateFont(template.User.Xp.Global.FontSize, FontStyle.Bold))
|
new RichTextOptions(_fonts.NotoSans.CreateFont(_template.User.Xp.Global.FontSize, FontStyle.Bold))
|
||||||
{
|
{
|
||||||
HorizontalAlignment = HorizontalAlignment.Center,
|
HorizontalAlignment = HorizontalAlignment.Center,
|
||||||
VerticalAlignment = VerticalAlignment.Center,
|
VerticalAlignment = VerticalAlignment.Center,
|
||||||
Origin = new(template.User.Xp.Global.Pos.X, template.User.Xp.Global.Pos.Y),
|
Origin = new(_template.User.Xp.Global.Pos.X, _template.User.Xp.Global.Pos.Y),
|
||||||
},
|
},
|
||||||
$"{global.LevelXp}/{global.RequiredXp}",
|
$"{global.LevelXp}/{global.RequiredXp}",
|
||||||
Brushes.Solid(template.User.Xp.Global.Color),
|
Brushes.Solid(_template.User.Xp.Global.Color),
|
||||||
outlinePen));
|
outlinePen));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (template.User.Xp.Guild.Show)
|
if (_template.User.Xp.Guild.Show)
|
||||||
{
|
{
|
||||||
img.Mutate(x => x.DrawText(
|
img.Mutate(x => x.DrawText(
|
||||||
new RichTextOptions(_fonts.NotoSans.CreateFont(template.User.Xp.Guild.FontSize, FontStyle.Bold))
|
new RichTextOptions(_fonts.NotoSans.CreateFont(_template.User.Xp.Guild.FontSize, FontStyle.Bold))
|
||||||
{
|
{
|
||||||
HorizontalAlignment = HorizontalAlignment.Center,
|
HorizontalAlignment = HorizontalAlignment.Center,
|
||||||
VerticalAlignment = VerticalAlignment.Center,
|
VerticalAlignment = VerticalAlignment.Center,
|
||||||
Origin = new(template.User.Xp.Guild.Pos.X, template.User.Xp.Guild.Pos.Y)
|
Origin = new(_template.User.Xp.Guild.Pos.X, _template.User.Xp.Guild.Pos.Y)
|
||||||
},
|
},
|
||||||
$"{guild.LevelXp}/{guild.RequiredXp}",
|
$"{guild.LevelXp}/{guild.RequiredXp}",
|
||||||
Brushes.Solid(template.User.Xp.Guild.Color),
|
Brushes.Solid(_template.User.Xp.Guild.Color),
|
||||||
outlinePen));
|
outlinePen));
|
||||||
}
|
}
|
||||||
|
|
||||||
var rankPen = new SolidPen(Color.White, 1);
|
var rankPen = new SolidPen(Color.White, 1);
|
||||||
//ranking
|
//ranking
|
||||||
if (template.User.GlobalRank.Show)
|
if (_template.User.GlobalRank.Show)
|
||||||
{
|
{
|
||||||
var globalRankStr = stats.GlobalRanking.ToString();
|
var globalRankStr = stats.GlobalRanking.ToString();
|
||||||
|
|
||||||
var globalRankFont = GetTruncatedFont(
|
var globalRankFont = GetTruncatedFont(
|
||||||
_fonts.UniSans,
|
_fonts.UniSans,
|
||||||
template.User.GlobalRank.FontSize,
|
_template.User.GlobalRank.FontSize,
|
||||||
FontStyle.Bold,
|
FontStyle.Bold,
|
||||||
globalRankStr,
|
globalRankStr,
|
||||||
68);
|
68);
|
||||||
|
@ -1153,21 +1151,21 @@ public class XpService : IEService, IReadyExecutor, IExecNoCommand
|
||||||
img.Mutate(x => x.DrawText(
|
img.Mutate(x => x.DrawText(
|
||||||
new RichTextOptions(globalRankFont)
|
new RichTextOptions(globalRankFont)
|
||||||
{
|
{
|
||||||
Origin = new(template.User.GlobalRank.Pos.X, template.User.GlobalRank.Pos.Y)
|
Origin = new(_template.User.GlobalRank.Pos.X, _template.User.GlobalRank.Pos.Y)
|
||||||
},
|
},
|
||||||
globalRankStr,
|
globalRankStr,
|
||||||
Brushes.Solid(template.User.GlobalRank.Color),
|
Brushes.Solid(_template.User.GlobalRank.Color),
|
||||||
rankPen
|
rankPen
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (template.User.GuildRank.Show)
|
if (_template.User.GuildRank.Show)
|
||||||
{
|
{
|
||||||
var guildRankStr = stats.GuildRanking.ToString();
|
var guildRankStr = stats.GuildRanking.ToString();
|
||||||
|
|
||||||
var guildRankFont = GetTruncatedFont(
|
var guildRankFont = GetTruncatedFont(
|
||||||
_fonts.UniSans,
|
_fonts.UniSans,
|
||||||
template.User.GuildRank.FontSize,
|
_template.User.GuildRank.FontSize,
|
||||||
FontStyle.Bold,
|
FontStyle.Bold,
|
||||||
guildRankStr,
|
guildRankStr,
|
||||||
43);
|
43);
|
||||||
|
@ -1175,16 +1173,16 @@ public class XpService : IEService, IReadyExecutor, IExecNoCommand
|
||||||
img.Mutate(x => x.DrawText(
|
img.Mutate(x => x.DrawText(
|
||||||
new RichTextOptions(guildRankFont)
|
new RichTextOptions(guildRankFont)
|
||||||
{
|
{
|
||||||
Origin = new(template.User.GuildRank.Pos.X, template.User.GuildRank.Pos.Y)
|
Origin = new(_template.User.GuildRank.Pos.X, _template.User.GuildRank.Pos.Y)
|
||||||
},
|
},
|
||||||
guildRankStr,
|
guildRankStr,
|
||||||
Brushes.Solid(template.User.GuildRank.Color),
|
Brushes.Solid(_template.User.GuildRank.Color),
|
||||||
rankPen
|
rankPen
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
//avatar
|
//avatar
|
||||||
if (template.User.Icon.Show)
|
if (_template.User.Icon.Show)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -1201,9 +1199,9 @@ public class XpService : IEService, IReadyExecutor, IExecNoCommand
|
||||||
using (var tempDraw = Image.Load<Rgba32>(avatarData))
|
using (var tempDraw = Image.Load<Rgba32>(avatarData))
|
||||||
{
|
{
|
||||||
tempDraw.Mutate(x => x
|
tempDraw.Mutate(x => x
|
||||||
.Resize(template.User.Icon.Size.X, template.User.Icon.Size.Y)
|
.Resize(_template.User.Icon.Size.X, _template.User.Icon.Size.Y)
|
||||||
.ApplyRoundedCorners(Math.Max(template.User.Icon.Size.X,
|
.ApplyRoundedCorners(Math.Max(_template.User.Icon.Size.X,
|
||||||
template.User.Icon.Size.Y)
|
_template.User.Icon.Size.Y)
|
||||||
/ 2.0f));
|
/ 2.0f));
|
||||||
await using (var stream = await tempDraw.ToStreamAsync())
|
await using (var stream = await tempDraw.ToStreamAsync())
|
||||||
{
|
{
|
||||||
|
@ -1216,11 +1214,11 @@ public class XpService : IEService, IReadyExecutor, IExecNoCommand
|
||||||
}
|
}
|
||||||
|
|
||||||
using var toDraw = Image.Load(data);
|
using var toDraw = Image.Load(data);
|
||||||
if (toDraw.Size != new Size(template.User.Icon.Size.X, template.User.Icon.Size.Y))
|
if (toDraw.Size != new Size(_template.User.Icon.Size.X, _template.User.Icon.Size.Y))
|
||||||
toDraw.Mutate(x => x.Resize(template.User.Icon.Size.X, template.User.Icon.Size.Y));
|
toDraw.Mutate(x => x.Resize(_template.User.Icon.Size.X, _template.User.Icon.Size.Y));
|
||||||
|
|
||||||
img.Mutate(x => x.DrawImage(toDraw,
|
img.Mutate(x => x.DrawImage(toDraw,
|
||||||
new Point(template.User.Icon.Pos.X, template.User.Icon.Pos.Y),
|
new Point(_template.User.Icon.Pos.X, _template.User.Icon.Pos.Y),
|
||||||
1));
|
1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1231,16 +1229,16 @@ public class XpService : IEService, IReadyExecutor, IExecNoCommand
|
||||||
}
|
}
|
||||||
|
|
||||||
//club image
|
//club image
|
||||||
if (template.Club.Icon.Show)
|
if (_template.Club.Icon.Show)
|
||||||
await DrawClubImage(img, stats);
|
await DrawClubImage(img, stats);
|
||||||
|
|
||||||
// #if GLOBAL_ELLIE
|
// #if GLOBAL_ELLIE
|
||||||
await DrawFrame(img, stats.User.UserId);
|
await DrawFrame(img, stats.User.UserId);
|
||||||
// #endif
|
// #endif
|
||||||
|
|
||||||
var outputSize = template.OutputSize;
|
var outputSize = _template.OutputSize;
|
||||||
if (outputSize.X != img.Width || outputSize.Y != img.Height)
|
if (outputSize.X != img.Width || outputSize.Y != img.Height)
|
||||||
img.Mutate(x => x.Resize(template.OutputSize.X, template.OutputSize.Y));
|
img.Mutate(x => x.Resize(_template.OutputSize.X, _template.OutputSize.Y));
|
||||||
|
|
||||||
var imageFormat = img.Metadata.DecodedImageFormat;
|
var imageFormat = img.Metadata.DecodedImageFormat;
|
||||||
var output = ((Stream)await img.ToStreamAsync(imageFormat), imageFormat);
|
var output = ((Stream)await img.ToStreamAsync(imageFormat), imageFormat);
|
||||||
|
@ -1364,9 +1362,9 @@ public class XpService : IEService, IReadyExecutor, IExecNoCommand
|
||||||
using (var tempDraw = Image.Load<Rgba32>(imgData))
|
using (var tempDraw = Image.Load<Rgba32>(imgData))
|
||||||
{
|
{
|
||||||
tempDraw.Mutate(x => x
|
tempDraw.Mutate(x => x
|
||||||
.Resize(template.Club.Icon.Size.X, template.Club.Icon.Size.Y)
|
.Resize(_template.Club.Icon.Size.X, _template.Club.Icon.Size.Y)
|
||||||
.ApplyRoundedCorners(Math.Max(template.Club.Icon.Size.X,
|
.ApplyRoundedCorners(Math.Max(_template.Club.Icon.Size.X,
|
||||||
template.Club.Icon.Size.Y)
|
_template.Club.Icon.Size.Y)
|
||||||
/ 2.0f));
|
/ 2.0f));
|
||||||
await using (var tds = await tempDraw.ToStreamAsync())
|
await using (var tds = await tempDraw.ToStreamAsync())
|
||||||
{
|
{
|
||||||
|
@ -1379,12 +1377,12 @@ public class XpService : IEService, IReadyExecutor, IExecNoCommand
|
||||||
}
|
}
|
||||||
|
|
||||||
using var toDraw = Image.Load(data);
|
using var toDraw = Image.Load(data);
|
||||||
if (toDraw.Size != new Size(template.Club.Icon.Size.X, template.Club.Icon.Size.Y))
|
if (toDraw.Size != new Size(_template.Club.Icon.Size.X, _template.Club.Icon.Size.Y))
|
||||||
toDraw.Mutate(x => x.Resize(template.Club.Icon.Size.X, template.Club.Icon.Size.Y));
|
toDraw.Mutate(x => x.Resize(_template.Club.Icon.Size.X, _template.Club.Icon.Size.Y));
|
||||||
|
|
||||||
img.Mutate(x => x.DrawImage(
|
img.Mutate(x => x.DrawImage(
|
||||||
toDraw,
|
toDraw,
|
||||||
new Point(template.Club.Icon.Pos.X, template.Club.Icon.Pos.Y),
|
new Point(_template.Club.Icon.Pos.X, _template.Club.Icon.Pos.Y),
|
||||||
1));
|
1));
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
|
Loading…
Add table
Reference in a new issue