Skip to content

Commit

Permalink
Changes on Author URLs
Browse files Browse the repository at this point in the history
Now the Author Label can have multiple links for mods that have more
then one author.
This should also make Author Links safer as it now has to start with
"http".
  • Loading branch information
thesupersonic16 committed Apr 9, 2017
1 parent 72f23e1 commit 974f033
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions SLWModLoader/src/DescriptionForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,19 @@ public DescriptionForm(string description, string title, string author, string d
descriptionLbl.Text = description.Replace("\\n", "\n");
titleLbl.Text = title + " v"+ version;
authorLbl.Text = $"Made by {author} on {date}";
if(authorUrl.Length > 0)
authorLbl.LinkArea = new LinkArea(8, author.Length);
this.authorUrl = authorUrl;

if (authorUrl.Length > 0)
{
int i = 0;
var autherSplit = author.Split(new string[] { " & " }, StringSplitOptions.None);
var authorUrlSplit = authorUrl.Split(new string[] { " & " }, StringSplitOptions.None);
foreach (string str in autherSplit)
{
authorLbl.Links.Add(new LinkLabel.Link(8 + i, str.Length, authorUrlSplit[Array.IndexOf(autherSplit, str)]));
i += str.Length + 3;
}
}
}

public DescriptionForm(Mod mod)
Expand Down Expand Up @@ -162,7 +172,15 @@ private void okbtn_Click(object sender, EventArgs e)

private void authorLbl_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
Process.Start(authorUrl);
try
{
if (e.Link.LinkData == null || (e.Link.LinkData as string).Length == 0) return;
if((e.Link.LinkData as string).StartsWith("http"))
{
Process.Start(e.Link.LinkData as string);
}
}
catch { }
}
}
}

0 comments on commit 974f033

Please sign in to comment.