Skip to content
Merged
31 changes: 28 additions & 3 deletions Controls/Grid.cs
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,27 @@ private string EscapeQuotes(string value, char escapeCharacter = ',') {
}
return value;
}

#region Export event handlers
private void exportItemCSV_Click(object sender, EventArgs e) {
ExportCsv();
}

private void exportItemHTML_Click(object sender, EventArgs e) {
ExportHtml();
}

private void exportItemBBCODE_Click(object sender, EventArgs e) {
ExportBbCode();
}

private void exportItemMD_Click(object sender, EventArgs e) {
ExportMarkdown();
}
#endregion

#region Export methods
public void ExportCsv() {
try {
saveFile.Filter = "CSV files|*.csv";
if (saveFile.ShowDialog() == DialogResult.OK) {
Expand Down Expand Up @@ -237,7 +257,8 @@ private void exportItemCSV_Click(object sender, EventArgs e) {
ControlErrors.HandleException(this, ex, false);
}
}
private void exportItemHTML_Click(object sender, EventArgs e) {

public void ExportHtml() {
try {
List<DataGridViewColumn> columns = GetSortedColumns();

Expand Down Expand Up @@ -271,7 +292,8 @@ private void exportItemHTML_Click(object sender, EventArgs e) {
ControlErrors.HandleException(this, ex, false);
}
}
private void exportItemBBCODE_Click(object sender, EventArgs e) {

public void ExportBbCode() {
try {
List<DataGridViewColumn> columns = GetSortedColumns();

Expand Down Expand Up @@ -305,7 +327,8 @@ private void exportItemBBCODE_Click(object sender, EventArgs e) {
ControlErrors.HandleException(this, ex, false);
}
}
private void exportItemMD_Click(object sender, EventArgs e) {

public void ExportMarkdown() {
try {
List<DataGridViewColumn> columns = GetSortedColumns();

Expand Down Expand Up @@ -341,6 +364,8 @@ private void exportItemMD_Click(object sender, EventArgs e) {
ControlErrors.HandleException(this, ex, false);
}
}
#endregion

private List<DataGridViewColumn> GetSortedColumns() {
List<DataGridViewColumn> columns = new List<DataGridViewColumn>();
foreach (DataGridViewColumn col in this.Columns) {
Expand Down
1 change: 1 addition & 0 deletions Entities/UserSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,6 @@ public class UserSettings {
public bool IgnoreLevelTypeWhenSorting { get; set; }
public string GameExeLocation { get; set; }
public bool AutoLaunchGameOnStartup { get; set; }
public string OverlayFontSerialized { get; set; }
}
}
39 changes: 21 additions & 18 deletions Views/Overlay.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
using NewTek.NDI;
using System;
using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
using System.Drawing.Text;
using System.IO;
using System.IO.Compression;
using System.Runtime.InteropServices;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace FallGuysStats {
public partial class Overlay : Form {
Expand Down Expand Up @@ -102,23 +99,23 @@ public Overlay() {

SetFonts(this);

this.DoubleBuffered = true;
this.SetStyle(ControlStyles.ResizeRedraw, true);
DoubleBuffered = true;
SetStyle(ControlStyles.ResizeRedraw, true);
}
protected override void WndProc(ref Message m) {
if (m.Msg == 0x84) {
Point pos = this.PointToClient(new Point(m.LParam.ToInt32()));
Point pos = PointToClient(new Point(m.LParam.ToInt32()));
int hitSize = 16;
if (pos.X >= this.ClientSize.Width - hitSize && pos.Y >= this.ClientSize.Height - hitSize) {
if (pos.X >= ClientSize.Width - hitSize && pos.Y >= ClientSize.Height - hitSize) {
m.Result = (IntPtr)17;
return;
} else if (pos.X <= hitSize && pos.Y >= this.ClientSize.Height - hitSize) {
} else if (pos.X <= hitSize && pos.Y >= ClientSize.Height - hitSize) {
m.Result = (IntPtr)16;
return;
} else if (pos.X <= hitSize && pos.Y <= hitSize) {
m.Result = (IntPtr)13;
return;
} else if (pos.X >= this.ClientSize.Width - hitSize && pos.Y <= hitSize) {
} else if (pos.X >= ClientSize.Width - hitSize && pos.Y <= hitSize) {
m.Result = (IntPtr)14;
return;
}
Expand Down Expand Up @@ -151,10 +148,10 @@ private void Overlay_MouseDown(object sender, MouseEventArgs e) {
private void UpdateTimer() {
while (StatsForm != null && !StatsForm.IsDisposed && !StatsForm.Disposing) {
try {
if (this.IsHandleCreated && !this.Disposing && !this.IsDisposed) {
if (IsHandleCreated && !Disposing && !IsDisposed) {
frameCount++;
isTimeToSwitch = frameCount % (StatsForm.CurrentSettings.CycleTimeSeconds * 20) == 0;
this.Invoke((Action)UpdateInfo);
Invoke((Action)UpdateInfo);
}

StatsForm.UpdateDates();
Expand All @@ -172,13 +169,13 @@ private void SetQualifyChanceLabel(StatSummary levelInfo) {
switch (qualifySwitchCount % 2) {
case 0:
lblQualifyChance.Text = "QUALIFY:";
qualifyChance = (float)levelInfo.TotalQualify * 100f / (levelInfo.TotalPlays == 0 ? 1 : levelInfo.TotalPlays);
qualifyChance = levelInfo.TotalQualify * 100f / (levelInfo.TotalPlays == 0 ? 1 : levelInfo.TotalPlays);
qualifyChanceDisplay = StatsForm.CurrentSettings.HideOverlayPercentages ? string.Empty : $" - {qualifyChance:0.0}%";
lblQualifyChance.TextRight = $"{levelInfo.TotalQualify} / {levelInfo.TotalPlays}{qualifyChanceDisplay}";
break;
case 1:
lblQualifyChance.Text = "GOLD:";
qualifyChance = (float)levelInfo.TotalGolds * 100f / (levelInfo.TotalPlays == 0 ? 1 : levelInfo.TotalPlays);
qualifyChance = levelInfo.TotalGolds * 100f / (levelInfo.TotalPlays == 0 ? 1 : levelInfo.TotalPlays);
qualifyChanceDisplay = StatsForm.CurrentSettings.HideOverlayPercentages ? string.Empty : $" - {qualifyChance:0.0}%";
lblQualifyChance.TextRight = $"{levelInfo.TotalGolds} / {levelInfo.TotalPlays}{qualifyChanceDisplay}";
break;
Expand Down Expand Up @@ -266,7 +263,7 @@ private void UpdateInfo() {
StatSummary levelInfo = StatsForm.GetLevelInfo(roundName);
lblName.TextRight = roundName;

float winChance = (float)levelInfo.TotalWins * 100f / (levelInfo.TotalShows == 0 ? 1 : levelInfo.TotalShows);
float winChance = levelInfo.TotalWins * 100f / (levelInfo.TotalShows == 0 ? 1 : levelInfo.TotalShows);
string winChanceDisplay = StatsForm.CurrentSettings.HideOverlayPercentages ? string.Empty : $" - {winChance:0.0}%";
if (StatsForm.CurrentSettings.PreviousWins > 0) {
lblWins.TextRight = $"{levelInfo.TotalWins} ({levelInfo.AllWins + StatsForm.CurrentSettings.PreviousWins}){winChanceDisplay}";
Expand All @@ -276,7 +273,7 @@ private void UpdateInfo() {
lblWins.TextRight = $"{levelInfo.TotalWins}{winChanceDisplay}";
}

float finalChance = (float)levelInfo.TotalFinals * 100f / (levelInfo.TotalShows == 0 ? 1 : levelInfo.TotalShows);
float finalChance = levelInfo.TotalFinals * 100f / (levelInfo.TotalShows == 0 ? 1 : levelInfo.TotalShows);
string finalText = $"{levelInfo.TotalFinals} / {levelInfo.TotalShows}";
string finalChanceDisplay = StatsForm.CurrentSettings.HideOverlayPercentages ? string.Empty : finalText.Length > 9 ? $" - {finalChance:0}%" : $" - {finalChance:0.0}%";
lblFinals.TextRight = $"{finalText}{finalChanceDisplay}";
Expand Down Expand Up @@ -349,7 +346,7 @@ private void UpdateInfo() {
lblDuration.TextRight = "-";
}
}
this.Invalidate();
Invalidate();
}

if (StatsForm.CurrentSettings.UseNDI) {
Expand Down Expand Up @@ -472,7 +469,7 @@ public void SetBackgroundColor(int colorOption) {
case 5: BackColor = Color.Green; break;
}
}
public void ArrangeDisplay(bool flipDisplay, bool showTabs, bool hideWins, bool hideRound, bool hideTime, int colorOption, int? width, int? height) {
public void ArrangeDisplay(bool flipDisplay, bool showTabs, bool hideWins, bool hideRound, bool hideTime, int colorOption, int? width, int? height, string serializedFont) {
FlipDisplay(false);

int heightOffset = showTabs ? 35 : 0;
Expand Down Expand Up @@ -645,6 +642,12 @@ public void ArrangeDisplay(bool flipDisplay, bool showTabs, bool hideWins, bool
break;
}

if (!string.IsNullOrEmpty(serializedFont)) {
SetFonts(this, -1,new FontConverter().ConvertFromString(serializedFont) as Font);
} else {
SetFonts(this);
}

DisplayTabs(showTabs);
FlipDisplay(flipDisplay);
SetBackgroundColor(colorOption);
Expand Down
Loading