Skip to content

Commit

Permalink
style: code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
DorielRivalet committed Apr 24, 2023

Partially verified

This commit is signed with the committer’s verified signature.
codebytere’s contribution has been verified via GPG key.
We cannot verify signatures from co-authors, and some of the co-authors attributed to this commit require their commits to be signed.
1 parent e100fcd commit 6889a0c
Showing 18 changed files with 76 additions and 132 deletions.
4 changes: 2 additions & 2 deletions MHFZ_Overlay/ConfigWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -833,7 +833,7 @@ public void DefaultKey_Press()
private void DefaultButton_Click(object sender, RoutedEventArgs e)
{
var result = MessageBox.Show("Resetting settings, are you sure?", "MHFZ Overlay - Confirmation", MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No);
if (result == MessageBoxResult.Yes)
if (result == MessageBoxResult.Yes)
{
Settings s = (Settings)Application.Current.TryFindResource("Settings");
DisposeAllWebViews();
@@ -1953,7 +1953,7 @@ private void SetLineSeriesForDictionaryIntDouble(Dictionary<int, double> data)
graphChart.YAxes = YAxes;
}

private void SetLineSeriesForPersonalBestByAttempts(Dictionary<long,long> data)
private void SetLineSeriesForPersonalBestByAttempts(Dictionary<long, long> data)
{
List<ISeries> series = new();
ObservableCollection<ObservablePoint> collection = new();
15 changes: 5 additions & 10 deletions MHFZ_Overlay/Core/Class/DataAccessLayer/DatabaseManager.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
using Dictionary;
using FluentMigrator.Runner;
using MHFZ_Overlay.UI.Class;
using MHFZ_Overlay.UI.Class.Mapper;
using Microsoft.Extensions.DependencyInjection;
using Newtonsoft.Json;
using NLog;
using Octokit;
using System;
using System.Collections.Generic;
using System.Data;
@@ -16,11 +13,9 @@
using System.Security.Cryptography;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media.Imaging;
using System.Windows.Threading;
using Formatting = Newtonsoft.Json.Formatting;

// TODO: PascalCase for functions, camelCase for private fields, ALL_CAPS for constants
@@ -527,9 +522,9 @@ public int InsertQuestData(DataLoader dataLoader, int attempts)
finalTimeValue, finalTimeDisplay, objectiveImage, objectiveTypeID, objectiveQuantity,
starGrade, rankName, objectiveName, date, attackBuffDictionary,
hitCountDictionary, hitsPerSecondDictionary, damageDealtDictionary, damagePerSecondDictionary, areaChangesDictionary,
cartsDictionary, hitsTakenBlockedDictionary, hitsTakenBlockedPerSecondDictionary, playerHPDictionary, playerStaminaDictionary,
keystrokesDictionary, mouseInputDictionary, gamepadInputDictionary, actionsPerMinuteDictionary, overlayModeDictionary,
actualOverlayMode, partySize, monster1HPDictionary, monster2HPDictionary, monster3HPDictionary,
cartsDictionary, hitsTakenBlockedDictionary, hitsTakenBlockedPerSecondDictionary, playerHPDictionary, playerStaminaDictionary,
keystrokesDictionary, mouseInputDictionary, gamepadInputDictionary, actionsPerMinuteDictionary, overlayModeDictionary,
actualOverlayMode, partySize, monster1HPDictionary, monster2HPDictionary, monster3HPDictionary,
monster4HPDictionary, monster1AttackMultiplierDictionary, monster1DefenseRateDictionary, monster1SizeMultiplierDictionary, monster1PoisonThresholdDictionary,
monster1SleepThresholdDictionary, monster1ParalysisThresholdDictionary, monster1BlastThresholdDictionary, monster1StunThresholdDictionary
);
@@ -7881,7 +7876,7 @@ private void UpdateDatabaseSchema(SQLiteConnection connection)
if (MainWindow.CurrentProgramVersion.Trim() != previousVersion.Trim())
{
MessageBoxResult result = MessageBox.Show("A new version of the program has been installed. Do you want to perform the necessary database updates? A backup of your current MHFZ_Overlay.sqlite file will be done if you accept.\n\nUpdating the database structure may take some time.",
string.Format("Program Update ({0} to {1})",previousVersion,MainWindow.CurrentProgramVersion), MessageBoxButton.YesNo, MessageBoxImage.Question);
string.Format("Program Update ({0} to {1})", previousVersion, MainWindow.CurrentProgramVersion), MessageBoxButton.YesNo, MessageBoxImage.Question);
if (result == MessageBoxResult.Yes)
{
// Make a backup of the current SQLite file before updating the schema
@@ -8196,7 +8191,7 @@ private void WritePreviousVersionToFile()
writer.WriteLine(previousVersion);
}
}
catch(Exception ex)
catch (Exception ex)
{
logger.Error(ex, "FILE OPERATION: Error with version file");
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Collections.Generic;

namespace Dictionary
{
@@ -96,7 +92,7 @@ public static class BingoMonsterDifficulty
"Zenith★2 Gravios",
"Zenith★2 Doragyurosu",
"Zenith★2 Bogabadorumu",
}
}
},
{"Medium", new List<string>{
"Zenith★3 Espinas",
@@ -130,7 +126,7 @@ public static class BingoMonsterDifficulty
"Lv9999 Crimson Fatalis",
"Lv9999 Shantien",
"2nd District Duremudira"
}
}
},
{"Hard", new List<string>{
"Zenith★4 Espinas",
@@ -165,7 +161,7 @@ public static class BingoMonsterDifficulty
"Golden Deviljho",
"Upper Shiten Unknown",
"Upper Shiten Disufiroa"
}
}
}
};
}
8 changes: 1 addition & 7 deletions MHFZ_Overlay/Core/Enum/Bitfields.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
using Discord;
using System;
using System.Collections.Generic;
using System;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Text.Json.Serialization;
using System.Threading.Tasks;
using System.Windows.Forms;

/*
[Flags]: Indicates that an enum is intended to be used as a bit field,
8 changes: 1 addition & 7 deletions MHFZ_Overlay/Core/Enum/Enums.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Text.Json.Serialization;
using System.Text.Json.Serialization;

namespace MHFZ_Overlay.Core.Enum
{
14 changes: 6 additions & 8 deletions MHFZ_Overlay/DataLoader.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
using Discord.Rest;
using Memory;
using Memory;
using MHFZ_Overlay.addresses;
using NLog;
using Octokit;
using Squirrel;
using System;
using System.Collections.Generic;
@@ -43,7 +41,7 @@ public void BackupSettings()
string destination = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "\\..\\last.config";
File.Copy(settingsFile, destination, true);
logger.Info("FILE OPERATION: Backed up settings. Original file: {0}, Destination: {1}", settingsFile, destination);
MessageBox.Show(string.Format("Backed up settings. Original file: {0}, Destination: {1}", settingsFile, destination), "MHF-Z Overlay Settings", MessageBoxButton.OK,MessageBoxImage.Information);
MessageBox.Show(string.Format("Backed up settings. Original file: {0}, Destination: {1}", settingsFile, destination), "MHF-Z Overlay Settings", MessageBoxButton.OK, MessageBoxImage.Information);
}

/// <summary>
@@ -69,7 +67,7 @@ private static void RestoreSettings()
logger.Info("FILE OPERATION: creating directory {0}", Path.GetDirectoryName(destFile));

}
catch (Exception ex)
catch (Exception ex)
{
logger.Info(ex, "FILE OPERATION: Did not make directory for {0}", destFile);
}
@@ -81,7 +79,7 @@ private static void RestoreSettings()
logger.Info("FILE OPERATION: copying {0} into {1}", sourceFile, destFile);

}
catch (Exception ex)
catch (Exception ex)
{
logger.Info(ex, "FILE OPERATION: Did not copy backup file. Source: {0}, Destination: {1} ", sourceFile, destFile);

@@ -94,7 +92,7 @@ private static void RestoreSettings()
logger.Info("FILE OPERATION: deleting {0}", sourceFile);

}
catch (Exception ex)
catch (Exception ex)
{
logger.Info(ex, "FILE OPERATION: Did not delete backup file. Source: {0}", sourceFile);
}
@@ -355,7 +353,7 @@ public void CheckForIllegalModifications()
// If there are any banned files or folders, display an error message and exit the application
string message = string.Format("The following files or folders are not allowed:\n{0}", string.Join("\n", illegalFiles));
MessageBox.Show(message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
logger.Fatal("FILE OPERATION: {0}",message);
logger.Fatal("FILE OPERATION: {0}", message);
Environment.Exit(0);
}
}
16 changes: 8 additions & 8 deletions MHFZ_Overlay/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -7,6 +7,8 @@
using LiveChartsCore.SkiaSharpView.Painting;
using Memory;
using MHFZ_Overlay.UI.Class;
using Microsoft.Extensions.DependencyModel;
using NLog;
using Octokit;
using SkiaSharp;
using System;
@@ -15,6 +17,7 @@
using System.Drawing;
using System.IO;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Automation;
@@ -38,10 +41,6 @@
using Label = System.Windows.Controls.Label;
using MouseEventArgs = System.Windows.Input.MouseEventArgs;
using Point = System.Windows.Point;
using NLog;
using System.Linq;
using Microsoft.Extensions.DependencyModel;
using System.Text;

namespace MHFZ_Overlay
{
@@ -687,7 +686,8 @@ private void CheckIfQuestChanged()
{
DataLoader.model.previousQuestID = DataLoader.model.QuestID();
ShowQuestName();
} else if (DataLoader.model.QuestID() == 0 && DataLoader.model.previousQuestID != 0)
}
else if (DataLoader.model.QuestID() == 0 && DataLoader.model.previousQuestID != 0)
{
DataLoader.model.previousQuestID = DataLoader.model.QuestID();
}
@@ -2100,7 +2100,7 @@ private void UpdateDiscordRPC()
{
return;
}

// TODO also need to handle the other fields lengths
if (string.Format("{0}{1}{2}{3}{4}{5}", GetPartySize(), GetQuestState(), GetCaravanScore(), DataLoader.model.GetOverlayModeForRPC(), DataLoader.model.GetAreaName(DataLoader.model.AreaID()), GetGameMode(DataLoader.isHighGradeEdition)).Length >= 95)
presenceTemplate.Details = string.Format("{0}{1}{2}", GetQuestState(), DataLoader.model.GetOverlayModeForRPC(), DataLoader.model.GetAreaName(DataLoader.model.AreaID()));
@@ -3248,9 +3248,9 @@ private void GlobalHookKeyUp(object sender, System.Windows.Forms.KeyEventArgs e)
{
if (_keyImages.ContainsKey(e.KeyCode))
{
Dispatcher.BeginInvoke(new Action(() =>
Dispatcher.BeginInvoke(new Action(() =>
{
_keyImages[e.KeyCode].Opacity = unpressedKeyOpacity;
_keyImages[e.KeyCode].Opacity = unpressedKeyOpacity;
}));
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
using System.Globalization;
using System;
using System.Globalization;
using System.Windows.Data;
using System.Windows.Media;
using System;

namespace MHFZ_Overlay {
namespace MHFZ_Overlay
{
public class TextFormattingModeConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
6 changes: 1 addition & 5 deletions MHFZ_Overlay/UI/Class/GearCompendium.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using Discord;
using MHFZ_Overlay.UI.Class;
using System;

namespace MHFZ_Overlay.UI.Class
namespace MHFZ_Overlay.UI.Class
{
//TODO: ORM
public class GearCompendium
8 changes: 2 additions & 6 deletions MHFZ_Overlay/UI/Class/Mapper/PersonalBestsMapper.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MHFZ_Overlay.UI.Class.Mapper
{
@@ -12,15 +8,15 @@ public class PersonalBestsMapper
public long Attempts { get; set; }
public DateTime CreatedAt { get; set; }
public string ActualOverlayMode { get; set; }
public long RunID { get;set; }
public long RunID { get; set; }
public long TimeLeft { get; set; }

public PersonalBestsMapper(string weaponType, long attempts, DateTime createdAt, string ActualOverlayMode, long runID, long timeLeft)
{
this.WeaponType = weaponType;
this.Attempts = attempts;
this.CreatedAt = createdAt;
this.ActualOverlayMode= ActualOverlayMode;
this.ActualOverlayMode = ActualOverlayMode;
this.RunID = runID;
this.TimeLeft = timeLeft;
}
6 changes: 1 addition & 5 deletions MHFZ_Overlay/UI/Class/MezFesCompendium.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using Discord;
using MHFZ_Overlay.UI.Class;
using System;

namespace MHFZ_Overlay.UI.Class
namespace MHFZ_Overlay.UI.Class
{
//TODO: ORM
public class MezFesCompendium
6 changes: 1 addition & 5 deletions MHFZ_Overlay/UI/Class/MiscellaneousCompendium.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using Discord;
using MHFZ_Overlay.UI.Class;
using System;

namespace MHFZ_Overlay.UI.Class
namespace MHFZ_Overlay.UI.Class
{
//TODO: ORM
public class MiscellaneousCompendium
9 changes: 2 additions & 7 deletions MHFZ_Overlay/UI/Class/PerformanceCompendium.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
using Discord;
using LiveChartsCore.Kernel;
using MHFZ_Overlay.UI.Class;
using System;

namespace MHFZ_Overlay.UI.Class
namespace MHFZ_Overlay.UI.Class
{
//TODO: ORM
public class PerformanceCompendium
@@ -41,7 +36,7 @@ public class PerformanceCompendium
public double ActionsPerMinuteMedian { get; set; }
public int HighestActionsPerMinuteRunID { get; set; }
public int TotalHitsCount { get; set; }
public int TotalHitsTakenBlocked { get;set; }
public int TotalHitsTakenBlocked { get; set; }
public int TotalActions { get; set; }
public double HealthAverage { get; set; }
public double HealthMedian { get; set; }
6 changes: 1 addition & 5 deletions MHFZ_Overlay/UI/Class/QuestCompendium.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using Discord;
using MHFZ_Overlay.UI.Class;
using System;

namespace MHFZ_Overlay.UI.Class
namespace MHFZ_Overlay.UI.Class
{
//TODO: ORM
public class QuestCompendium
7 changes: 1 addition & 6 deletions MHFZ_Overlay/UI/Class/RangeValidationRule.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Globalization;
using System.Windows.Controls;

namespace MHFZ_Overlay.UI.Class
Loading

0 comments on commit 6889a0c

Please sign in to comment.