From 091701e93136438a643175c3807fdd5c5cf840b7 Mon Sep 17 00:00:00 2001 From: appelemac Date: Tue, 7 Jun 2016 19:54:55 +0200 Subject: [PATCH] rip upgrade I'm not scaling the strings *hands off* --- .vs/NadekoBot/NadekoBot.scgdat | Bin 0 -> 131072 bytes .../Modules/Conversations/Conversations.cs | 58 +++++++++++++++++- NadekoBot/NadekoBot.csproj | 1 + NadekoBot/Properties/Resources.Designer.cs | 10 +++ NadekoBot/Properties/Resources.resx | 3 + NadekoBot/resources/images/rose_overlay.png | Bin 0 -> 18492 bytes 6 files changed, 70 insertions(+), 2 deletions(-) create mode 100644 .vs/NadekoBot/NadekoBot.scgdat create mode 100644 NadekoBot/resources/images/rose_overlay.png diff --git a/.vs/NadekoBot/NadekoBot.scgdat b/.vs/NadekoBot/NadekoBot.scgdat new file mode 100644 index 0000000000000000000000000000000000000000..e34ebe8d2ab64f089e47c182c8648a3a419a7573 GIT binary patch literal 131072 zcmeI*TWlQF8Nl(gu9!e-`)jZIo7lCN0ih2&%E*0hZ9N$L;uo4$4-@!$u4I>IrGlytWwKlCM`ej ztk-+EL#Ir>EQvF!?S6k-K%=M(EhnzL7(WiU}$yzEhus%%l3hy^BF{&x7M$ZKb6(?j5~ZQk}zRG zf99go1)sen?87Pq5V$@BYWj%lqe9dI0R#|0009ILK;W7a_+aR7x3zSHP@X z_czX%&XT^y{h7XKs0YCtJD{m&}-bU@Dg4K<}yUMWjWD^*akU+?FRO$G=cfB*srAb9(Nsy|Sz~6CIuw!!5PiWLD>nDkW`q9?bPr5-L1x_b=)*+Ej)Tz;m z`bqsLtLyKY+>F;;Lc&M`zPZs1!lwI$`blaV?J{TgZ2hjNes`P;vWmZ4L9=o*N#2|e zlF!j5-NZ>7Qy2B0LtTkE8=adtdGkWPT_83B2q1s}0thUyK<^91$ulR;k4!(UhAteL zdaC#9_E#@F-hF8L;J|_Y{TFxl7tinPzi+Cqf7`&;{>{aW7d8~T`&XY|`EHjg6c!h= z{c^7V>b@Thx6A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q1s}0tg_000IagfB*v5l7PPc|BX}cmveIc|GsOf;0st* z{X7Ky*@*x7NPH@r8ovI&fYl&00tg_000IagfB*srAb`LPCh+p}e@HKq>;FSHSiPw( z0tg_000IagfB*srAbUrgwAWHv$MCfB*srAbU-Zp1RKjZGd&JFJDZFdjeb5GyUjxD8fd2q}2q3wfP?zyv4+0s`Y z94eJ6_m(T$`>v9jQ49nSKmY**5I_I{1Q0*~0R#|;2*{=Wzpj7%rGlLQ|H|8t)#v|8 ze#xLe1^6tu*}XkdEl&5I_I{1Q0*~ z0R#|00D)^;z(4=LwrfG@5kLR|1Q0*~0R#|0009ILKmY**5I_I{1Q0*~0R#|0009IL zKmY**5I_I{1Q0*~0R#|0009ILKmY**5I_I{1Q0*~0R#|0009ILKmY**5I_I{1Q0*~ z0R#|0009ILKmY**5I_I{1Q0*~0R#|0009ILKmY**5I_I{1Q0*~0R#|0009ILKmY** z5I_I{1Q0*~0R#|0009ILKmY**5I_I{1Q0*~0R#|0009ILKmY**5I_I{1Q0*~0R#|0 L009ILa0UJkXGugR literal 0 HcmV?d00001 diff --git a/NadekoBot/Modules/Conversations/Conversations.cs b/NadekoBot/Modules/Conversations/Conversations.cs index b8de0cea..458108ce 100644 --- a/NadekoBot/Modules/Conversations/Conversations.cs +++ b/NadekoBot/Modules/Conversations/Conversations.cs @@ -1,6 +1,7 @@ using Discord; using Discord.Commands; using Discord.Modules; +using NadekoBot.Classes; using NadekoBot.Classes.Conversations.Commands; using NadekoBot.DataModels; using NadekoBot.Extensions; @@ -9,6 +10,7 @@ using NadekoBot.Properties; using System; using System.Diagnostics; using System.Drawing; +using System.Drawing.Drawing2D; using System.Drawing.Imaging; using System.IO; using System.Linq; @@ -194,13 +196,15 @@ namespace NadekoBot.Modules.Conversations return; var usr = e.Channel.FindUsers(e.GetArg("user")).FirstOrDefault(); var text = ""; + var avatar = await GetAvatar(usr.AvatarUrl); text = usr?.Name ?? e.GetArg("user"); await e.Channel.SendFile("ripzor_m8.png", - RipName(text, string.IsNullOrWhiteSpace(e.GetArg("year")) + RipUser(text, avatar, string.IsNullOrWhiteSpace(e.GetArg("year")) ? null : e.GetArg("year"))) .ConfigureAwait(false); }); + if (!NadekoBot.Config.DontJoinServers) { cgb.CreateCommand("j") @@ -351,7 +355,7 @@ namespace NadekoBot.Modules.Conversations { fontSize -= (name.Length - 10) / 2; } - + //TODO use measure string var g = Graphics.FromImage(bm); g.DrawString(name, new Font("Comic Sans MS", fontSize, FontStyle.Bold), Brushes.Black, 100 - offset, 200); @@ -362,6 +366,56 @@ namespace NadekoBot.Modules.Conversations return bm.ToStream(ImageFormat.Png); } + public Stream RipUser(string name, Image avatar, string year = null) + { + var bm = Resources.rip; + var offset = name.Length * 2; + + var fontSize = 20; + + if (name.Length > 10) + { + fontSize -= (name.Length - 10) / 2; + } + //var avatar = Image.FromStream(await SearchHelper.GetResponseStreamAsync(aviLink)); + + + + //TODO use measure string + var g = Graphics.FromImage(bm); + g.DrawString(name, new Font("Comic Sans MS", fontSize, FontStyle.Bold), Brushes.Black, 100 - offset, 220); + g.DrawString((year ?? "?") + " - " + DateTime.Now.Year, new Font("Consolas", 12, FontStyle.Bold), Brushes.Black, 80, 240); + + g.DrawImage(avatar, 80,135); + g.DrawImage((Image)Resources.rose_overlay, 0, 0); + g.Flush(); + g.Dispose(); + + return bm.ToStream(ImageFormat.Png); + + } + + + public static async Task GetAvatar(string url) + { + var stream = await SearchHelper.GetResponseStreamAsync(url); + Bitmap bmp = new Bitmap(100, 100); + using (GraphicsPath gp = new GraphicsPath()) + { + gp.AddEllipse(0,0, bmp.Width, bmp.Height); + using (Graphics gr = Graphics.FromImage(bmp)) + { + gr.SetClip(gp); + gr.DrawImage(Image.FromStream(stream), Point.Empty); + + } + } + return bmp; + + } + + + private static Func SayYes() => async e => await e.Channel.SendMessage("Yes. :)").ConfigureAwait(false); } diff --git a/NadekoBot/NadekoBot.csproj b/NadekoBot/NadekoBot.csproj index df37a039..afbc37af 100644 --- a/NadekoBot/NadekoBot.csproj +++ b/NadekoBot/NadekoBot.csproj @@ -492,6 +492,7 @@ +