Skip to content

Commit

Permalink
Bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
qubqub committed Oct 26, 2023
1 parent 8a30303 commit 9a87725
Show file tree
Hide file tree
Showing 8 changed files with 99 additions and 28 deletions.
17 changes: 17 additions & 0 deletions Controls/TransparentLabel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ private float GetFontSizeFactorForRoundName(string text) {

factor += (this.GetCountSpace(text) * factorOffsetForSpace)
+ (this.GetCountEngUppercase(text) * factorOffsetForEngUppercase) + (this.GetCountEngLowercase(text) * factorOffsetForEngLowercase)
+ (this.GetCountRusUppercase(text) * factorOffsetForEngUppercase) + (this.GetCountRusLowercase(text) * factorOffsetForEngLowercase)
+ (this.GetCountKorCharacter(text) * factorOffsetForKorCharacter)
+ (this.GetCountJpnCharacter(text) * factorOffsetForJpnCharacter) + (this.GetCountChineseCharacter(text) * factorOffsetForChineseCharacter)
+ (this.GetCountSignCharacter(text) * factorOffsetForSignCharacter) + (this.GetCountNumeric(text) * factorOffsetForNumeric);
Expand Down Expand Up @@ -388,6 +389,22 @@ private int GetCountEngLowercase(string s) {
}
return count;
}
private int GetCountRusUppercase(string s) {
int count = 0;
char[] charArr = s.ToCharArray();
foreach (char ch in charArr) {
if ((0x410 <= ch && ch <= 0x42F)) count++;
}
return count;
}
private int GetCountRusLowercase(string s) {
int count = 0;
char[] charArr = s.ToCharArray();
foreach (char ch in charArr) {
if ((0x430 <= ch && ch <= 0x44F)) count++;
}
return count;
}
private int GetCountSpace(string s) {
int count = 0;
char[] charArr = s.ToCharArray();
Expand Down
11 changes: 7 additions & 4 deletions Entities/LogFileWatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ public class LogFileWatcher {
public event Action<List<RoundInfo>> OnParsedLogLines;
public event Action<List<RoundInfo>> OnParsedLogLinesCurrent;
public event Action<DateTime> OnNewLogFileDate;
public event Action<string, string> OnShowToastNotification;
public event Action<string> OnError;

private readonly ServerPingWatcher serverPingWatcher = new ServerPingWatcher();
Expand Down Expand Up @@ -473,14 +474,13 @@ private void SetCountryCodeByIP(string ip) {
try {
string countryInfo = this.StatsForm.GetIpToCountryCode(ip);
string alpha2Code = countryInfo.Split(';')[0].ToLower();
string region = countryInfo.Split(';').Length > 1 ? countryInfo.Split(';')[1] : string.Empty;
Stats.LastCountryAlpha2Code = alpha2Code;
if (this.StatsForm.CurrentSettings.NotifyServerConnected && !string.IsNullOrEmpty(alpha2Code)) {
// this.StatsForm.ShowNotification(Multilingual.GetWord("message_connected_to_server_caption"),
// $"{Multilingual.GetWord("message_connected_to_server_prefix")} {Multilingual.GetCountryName(alpha2Code)}, {countryInfo.Split(';')[1]} {Multilingual.GetWord("message_connected_to_server_suffix")}",
// $"{Multilingual.GetWord("message_connected_to_server_prefix")}{Multilingual.GetCountryName(alpha2Code)}{(countryInfo.Split(';').Length > 1 ? $", {countryInfo.Split(';')[1]}" : "")}{Multilingual.GetWord("message_connected_to_server_suffix")}",
// System.Windows.Forms.ToolTipIcon.Info, 2000);
this.StatsForm.ShowToastNotification(Multilingual.GetWord("message_connected_to_server_caption"),
$"{Multilingual.GetWord("message_connected_to_server_prefix")}{Multilingual.GetCountryName(alpha2Code)}{(countryInfo.Split(';').Length > 1 ? $", {countryInfo.Split(';')[1]}" : "")}{Multilingual.GetWord("message_connected_to_server_suffix")}",
Position.BottomRight, Duration.LENGTH_LONG, Animation.FADE, this.StatsForm.Theme == MetroFramework.MetroThemeStyle.Light ? Theme.SuccessLight : Theme.SuccessDark, false);
this.OnShowToastNotification?.Invoke(alpha2Code, region);
}
} catch {
this.toggleCountryInfoApi = false;
Expand Down Expand Up @@ -742,6 +742,9 @@ private bool ParseLine(LogLine line, List<RoundInfo> round, LogRound logRound) {
}

Stats.ToggleServerInfo = false;
Stats.LastServerPing = 0;
Stats.IsBadServerPing = false;
Stats.LastCountryAlpha2Code = string.Empty;
this.toggleCountryInfoApi = false;
this.toggleFgdbCreativeApi = false;

Expand Down
6 changes: 6 additions & 0 deletions Entities/Multilingual.cs
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,7 @@ public static class Multilingual {
{"settings_select_language_button", "Confirm"},
{"settings_system_tray_icon", "Use the system tray icon"},
{"settings_notify_server_connected", "Windows notification with the country name of the server when the server is connected"},
{"settings_mute_notification_sounds", "Mute notification sounds"},
{"settings_prevent_overlay_mouse_clicks", "Prevent overlay mouse clicks"},
{"settings_github", "GitHub (ShootMe/FallGuysStats)"},
{"settings_issue_traker", "Issue Tracker"},
Expand Down Expand Up @@ -808,6 +809,7 @@ public static class Multilingual {
{"settings_select_language_button", "Confirmer"},
{"settings_system_tray_icon", "Utiliser l'icône de la barre des tâches"},
{"settings_notify_server_connected", "Notification Windows avec le nom du pays du serveur lorsque le serveur est connecté"},
{"settings_mute_notification_sounds", "Couper les sons des notifications"},
{"settings_prevent_overlay_mouse_clicks", "Prévenir les bogues du curseur de la souris"},
{"settings_github", "GitHub (ShootMe/FallGuysStats)"},
{"settings_issue_traker", "Issue Tracker"},
Expand Down Expand Up @@ -1255,6 +1257,7 @@ public static class Multilingual {
{"settings_select_language_button", "확인"},
{"settings_system_tray_icon", "작업 표시줄 아이콘 사용"},
{"settings_notify_server_connected", "서버가 연결되면 서버가 위치한 나라의 이름을 윈도우 알림으로 띄우기"},
{"settings_mute_notification_sounds", "알림 소리 음소거"},
{"settings_prevent_overlay_mouse_clicks", "오버레이 마우스 클릭 방지"},
{"settings_github", "깃허브 (ShootMe/FallGuysStats)"},
{"settings_issue_traker", "이슈 추적"},
Expand Down Expand Up @@ -1702,6 +1705,7 @@ public static class Multilingual {
{"settings_select_language_button", "保存"},
{"settings_system_tray_icon", "システムトレイアイコンを使用する"},
{"settings_notify_server_connected", "サーバー接続時にサーバーの国名を含む Windows 通知を送信する"},
{"settings_mute_notification_sounds", "M通知音をミュート"},
{"settings_prevent_overlay_mouse_clicks", "マウスカーソルの不具合を防ぐ"},
{"settings_github", "GitHub (ShootMe/FallGuysStats)"},
{"settings_issue_traker", "バグトラッカー"},
Expand Down Expand Up @@ -2149,6 +2153,7 @@ public static class Multilingual {
{"settings_select_language_button", "选择"},
{"settings_system_tray_icon", "使用系统托盘图标"},
{"settings_notify_server_connected", "连接服务器时,带有服务器国家/地区名称的 Windows 通知"},
{"settings_mute_notification_sounds", "将通知声音静音"},
{"settings_prevent_overlay_mouse_clicks", "防止鼠标光标错误"},
{"settings_github", "GitHub (ShootMe/FallGuysStats)"},
{"settings_issue_traker", "问题追踪器"},
Expand Down Expand Up @@ -2596,6 +2601,7 @@ public static class Multilingual {
{"settings_select_language_button", "選擇"},
{"settings_system_tray_icon", "使用系統托盤圖標"},
{"settings_notify_server_connected", "連接服務器時,帶有服務器國家/地區名稱的 Windows 通知"},
{"settings_mute_notification_sounds", "將通知聲音靜音"},
{"settings_prevent_overlay_mouse_clicks", "防止鼠標光標錯誤"},
{"settings_github", "GitHub (ShootMe/FallGuysStats)"},
{"settings_issue_traker", "問題追踪器"},
Expand Down
1 change: 1 addition & 0 deletions Entities/UserSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public class UserSettings {
public bool SystemTrayIcon { get; set; }
public bool PreventOverlayMouseClicks { get; set; }
public bool NotifyServerConnected { get; set; }
public bool MuteNotificationSounds { get; set; }
public bool MaximizedWindowState { get; set; }
public int? FormLocationX { get; set; }
public int? FormLocationY { get; set; }
Expand Down
Binary file modified EunmaToast.dll
Binary file not shown.
26 changes: 21 additions & 5 deletions Views/Settings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 13 additions & 1 deletion Views/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@ private void Settings_Load(object sender, EventArgs e) {
this.chkAutoUpdate.Checked = this.CurrentSettings.AutoUpdate;
this.chkSystemTrayIcon.Checked = this.CurrentSettings.SystemTrayIcon;
this.chkNotifyServerConnected.Checked = this.CurrentSettings.NotifyServerConnected;
this.chkMuteNotificationSounds.Enabled = this.chkNotifyServerConnected.Checked;
if (this.chkNotifyServerConnected.Checked) {
this.chkMuteNotificationSounds.Checked = this.CurrentSettings.MuteNotificationSounds;
}
this.chkPreventOverlayMouseClicks.Checked = this.CurrentSettings.PreventOverlayMouseClicks;
this.chkFlipped.Checked = this.CurrentSettings.FlippedDisplay;
this.chkHidePercentages.Checked = this.CurrentSettings.HideOverlayPercentages;
Expand Down Expand Up @@ -449,6 +453,7 @@ private void btnSave_Click(object sender, EventArgs e) {
this.CurrentSettings.AutoUpdate = this.chkAutoUpdate.Checked;
this.CurrentSettings.SystemTrayIcon = this.chkSystemTrayIcon.Checked;
this.CurrentSettings.NotifyServerConnected = this.chkNotifyServerConnected.Checked;
this.CurrentSettings.MuteNotificationSounds = this.chkMuteNotificationSounds.Checked;
this.CurrentSettings.PreventOverlayMouseClicks = this.chkPreventOverlayMouseClicks.Checked;
this.CurrentSettings.FlippedDisplay = this.chkFlipped.Checked;
this.CurrentSettings.HideOverlayPercentages = this.chkHidePercentages.Checked;
Expand Down Expand Up @@ -729,6 +734,12 @@ private void chkFallalyticsReporting_CheckedChanged(object sender, EventArgs e)
this.chkFallalyticsAnonymous.Checked = ((MetroCheckBox)sender).Checked;
}
}
private void chkNotifyServerConnected_CheckedChanged(object sender, EventArgs e) {
this.chkMuteNotificationSounds.Enabled = ((MetroCheckBox)sender).Checked;
if (!((MetroCheckBox)sender).Checked) {
this.chkMuteNotificationSounds.Checked = ((MetroCheckBox)sender).Checked;
}
}

private void ChangeLanguage(int lang) {
this.DisplayLang = lang;
Expand Down Expand Up @@ -887,6 +898,7 @@ private void ChangeLanguage(int lang) {
this.chkAutoUpdate.Text = Multilingual.GetWord("settings_auto_update_program");
this.chkSystemTrayIcon.Text = Multilingual.GetWord("settings_system_tray_icon");
this.chkNotifyServerConnected.Text = Multilingual.GetWord("settings_notify_server_connected");
this.chkMuteNotificationSounds.Text = Multilingual.GetWord("settings_mute_notification_sounds");
this.chkPreventOverlayMouseClicks.Text = Multilingual.GetWord("settings_prevent_overlay_mouse_clicks");
this.lblPreviousWinsNote.Text = Multilingual.GetWord("settings_before_using_tracker");
this.lblPreviousWins.Text = Multilingual.GetWord("settings_previous_win");
Expand All @@ -902,7 +914,7 @@ private void ChangeLanguage(int lang) {
this.txtLogPath.Size = new Size(630 - this.lblLogPath.Width - 4, 25);
this.txtPreviousWins.Location = new Point(this.lblPreviousWins.Location.X + this.lblPreviousWins.Width + 4, 10);
this.lblPreviousWinsNote.Location = new Point(this.txtPreviousWins.Location.X + this.txtPreviousWins.Width + 4, 12);
this.cboTheme.Location = new Point(this.lblTheme.Location.X + this.lblTheme.Width + 4, 200);
this.cboTheme.Location = new Point(this.lblTheme.Location.X + this.lblTheme.Width + 4, this.cboTheme.Location.Y);
this.txtCycleTimeSeconds.Location = new Point(this.lblCycleTimeSeconds.Location.X + this.lblCycleTimeSeconds.Width + 4, 167);
this.lblCycleTimeSecondsTag.Location = new Point(this.txtCycleTimeSeconds.Location.X + this.txtCycleTimeSeconds.Width + 4, 170);
if (this.LaunchPlatform == 0) {
Expand Down
Loading

0 comments on commit 9a87725

Please sign in to comment.