rip upgrade
I'm not scaling the strings *hands off*
This commit is contained in:
parent
d899f13f71
commit
091701e931
BIN
.vs/NadekoBot/NadekoBot.scgdat
Normal file
BIN
.vs/NadekoBot/NadekoBot.scgdat
Normal file
Binary file not shown.
@ -1,6 +1,7 @@
|
|||||||
using Discord;
|
using Discord;
|
||||||
using Discord.Commands;
|
using Discord.Commands;
|
||||||
using Discord.Modules;
|
using Discord.Modules;
|
||||||
|
using NadekoBot.Classes;
|
||||||
using NadekoBot.Classes.Conversations.Commands;
|
using NadekoBot.Classes.Conversations.Commands;
|
||||||
using NadekoBot.DataModels;
|
using NadekoBot.DataModels;
|
||||||
using NadekoBot.Extensions;
|
using NadekoBot.Extensions;
|
||||||
@ -9,6 +10,7 @@ using NadekoBot.Properties;
|
|||||||
using System;
|
using System;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
|
using System.Drawing.Drawing2D;
|
||||||
using System.Drawing.Imaging;
|
using System.Drawing.Imaging;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@ -194,13 +196,15 @@ namespace NadekoBot.Modules.Conversations
|
|||||||
return;
|
return;
|
||||||
var usr = e.Channel.FindUsers(e.GetArg("user")).FirstOrDefault();
|
var usr = e.Channel.FindUsers(e.GetArg("user")).FirstOrDefault();
|
||||||
var text = "";
|
var text = "";
|
||||||
|
var avatar = await GetAvatar(usr.AvatarUrl);
|
||||||
text = usr?.Name ?? e.GetArg("user");
|
text = usr?.Name ?? e.GetArg("user");
|
||||||
await e.Channel.SendFile("ripzor_m8.png",
|
await e.Channel.SendFile("ripzor_m8.png",
|
||||||
RipName(text, string.IsNullOrWhiteSpace(e.GetArg("year"))
|
RipUser(text, avatar, string.IsNullOrWhiteSpace(e.GetArg("year"))
|
||||||
? null
|
? null
|
||||||
: e.GetArg("year")))
|
: e.GetArg("year")))
|
||||||
.ConfigureAwait(false);
|
.ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!NadekoBot.Config.DontJoinServers)
|
if (!NadekoBot.Config.DontJoinServers)
|
||||||
{
|
{
|
||||||
cgb.CreateCommand("j")
|
cgb.CreateCommand("j")
|
||||||
@ -351,7 +355,7 @@ namespace NadekoBot.Modules.Conversations
|
|||||||
{
|
{
|
||||||
fontSize -= (name.Length - 10) / 2;
|
fontSize -= (name.Length - 10) / 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO use measure string
|
//TODO use measure string
|
||||||
var g = Graphics.FromImage(bm);
|
var g = Graphics.FromImage(bm);
|
||||||
g.DrawString(name, new Font("Comic Sans MS", fontSize, FontStyle.Bold), Brushes.Black, 100 - offset, 200);
|
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);
|
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<Image> 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<CommandEventArgs, Task> SayYes()
|
private static Func<CommandEventArgs, Task> SayYes()
|
||||||
=> async e => await e.Channel.SendMessage("Yes. :)").ConfigureAwait(false);
|
=> async e => await e.Channel.SendMessage("Yes. :)").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
@ -492,6 +492,7 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Content Include="lib\ScaredFingers.UnitsConversion.dll" />
|
<Content Include="lib\ScaredFingers.UnitsConversion.dll" />
|
||||||
|
<None Include="resources\images\rose_overlay.png" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
|
10
NadekoBot/Properties/Resources.Designer.cs
generated
10
NadekoBot/Properties/Resources.Designer.cs
generated
@ -730,6 +730,16 @@ namespace NadekoBot.Properties {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||||
|
/// </summary>
|
||||||
|
public static System.Drawing.Bitmap rose_overlay {
|
||||||
|
get {
|
||||||
|
object obj = ResourceManager.GetObject("rose_overlay", resourceCulture);
|
||||||
|
return ((System.Drawing.Bitmap)(obj));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -322,4 +322,7 @@
|
|||||||
<data name="_9_of_spades" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
<data name="_9_of_spades" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
<value>..\resources\images\cards\9_of_spades.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
<value>..\resources\images\cards\9_of_spades.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="rose_overlay" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
|
<value>..\resources\images\rose_overlay.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
|
</data>
|
||||||
</root>
|
</root>
|
BIN
NadekoBot/resources/images/rose_overlay.png
Normal file
BIN
NadekoBot/resources/images/rose_overlay.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 18 KiB |
Loading…
Reference in New Issue
Block a user