Skip to content

Commit

Permalink
fix: code smells
Browse files Browse the repository at this point in the history
  • Loading branch information
DorielRivalet committed Nov 20, 2022
1 parent 0ee8d4f commit 3546a4e
Show file tree
Hide file tree
Showing 5 changed files with 92 additions and 44 deletions.
2 changes: 1 addition & 1 deletion MHFZ_Overlay/ConfigWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public static string getFeriasLink()
return s.FeriasVersionLink;
}

public MonsterInfo[] monsterInfos = new MonsterInfo[]
private MonsterInfo[] monsterInfos = new MonsterInfo[]
{
new MonsterInfo("[Musou] Arrogant Duremudira",
"https://dorielrivalet.github.io/MHFZ-Ferias-English-Project/mons/dolem_n.htm",
Expand Down
12 changes: 8 additions & 4 deletions MHFZ_Overlay/DataLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,14 @@ public class DataLoader
#region DataLoaderVariables
//needed for getting data
readonly Mem m = new();
public bool isHighGradeEdition;
public bool isInLauncher;
public bool closedGame;
private bool isHighGradeEdition;

public bool IsHighGradeEdition
{
get { return isHighGradeEdition; }
set { isHighGradeEdition = value; }
}

int index;
/// <summary>
/// Gets the model.
Expand Down Expand Up @@ -198,6 +203,5 @@ void WriteByteFromAddress(UIntPtr codecaveAddress, Process proc, long offset1, i
}
return proccess;
}

}
}
38 changes: 20 additions & 18 deletions MHFZ_Overlay/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ protected override void OnSourceInitialized(EventArgs e)
/// <value>
/// The client.
/// </value>
public DiscordRpcClient Client;
private DiscordRpcClient Client;

//Called when your application first starts.
//For example, just before your main loop, on OnEnable for unity.
Expand Down Expand Up @@ -262,7 +262,7 @@ void Cleanup()
/// <summary>
/// Is the main loop currently running?
/// </summary>
public bool isDiscordRPCRunning = false;
private bool isDiscordRPCRunning = false;

/// <summary>
/// Initializes the discord RPC.
Expand Down Expand Up @@ -291,7 +291,7 @@ private void InitializeDiscordRPC()
}

//should work fine
presenceTemplate.Buttons = new DiscordRPC.Button[] { }; ;
presenceTemplate.Buttons = new DiscordRPC.Button[] { };
presenceTemplate.Buttons = new DiscordRPC.Button[]
{
new DiscordRPC.Button() {Label = "【MHF-Z】Overlay "+CurrentProgramVersion, Url = "https://github.com/DorielRivalet/MHFZ_Overlay"},
Expand All @@ -300,7 +300,7 @@ private void InitializeDiscordRPC()

if (GetDiscordServerInvite != "")
{
presenceTemplate.Buttons = new DiscordRPC.Button[] { }; ;
presenceTemplate.Buttons = new DiscordRPC.Button[] { };
presenceTemplate.Buttons = new DiscordRPC.Button[]
{
new DiscordRPC.Button() {Label = "【MHF-Z】Overlay "+CurrentProgramVersion, Url = "https://github.com/DorielRivalet/MHFZ_Overlay"},
Expand Down Expand Up @@ -395,7 +395,9 @@ private static void OpenLink(string destinationurl)
System.Diagnostics.Process.Start(sInfo);
}

public bool isLatestRelease;
private bool isLatestRelease;
private bool closedGame;
private bool isInLauncherBool;

public void CheckGameState()
{
Expand All @@ -418,11 +420,11 @@ public void CheckGameState()
if (className == "MHFLAUNCH")
{
System.Windows.MessageBox.Show("Detected launcher, please restart overlay when fully loading into Mezeporta.", "Error", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Error);
DataLoader.isInLauncher = true;
isInLauncherBool = true;
}
else
{
DataLoader.isInLauncher = false;
isInLauncherBool = false;
}

//https://stackoverflow.com/questions/51148/how-do-i-find-out-if-a-process-is-already-running-using-c
Expand All @@ -432,8 +434,8 @@ public void CheckGameState()
mhfProcess.EnableRaisingEvents = true;
mhfProcess.Exited += (sender, e) =>
{
DataLoader.closedGame = true;

closedGame = true;
Settings s = (Settings)Application.Current.TryFindResource("Settings");

if (s.EnableAutoClose)
Expand All @@ -448,7 +450,7 @@ public void CheckGameState()
System.Windows.MessageBox.Show("Detected closed game, please restart overlay when fully loading into Mezeporta.", "Warning", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Warning);
}
};
};
}
}


Expand Down Expand Up @@ -1487,9 +1489,9 @@ public string GetOverlayMode()

if (DataLoader.model.Configuring)
return "(Configuring) ";
else if (DataLoader.closedGame)
else if (closedGame)
return "(Closed Game) ";
else if (DataLoader.isInLauncher || isInLauncher() == "Yes") //works?
else if (isInLauncherBool || isInLauncher() == "Yes") //works?
return "(Launcher) ";
else if (isInLauncher() == "NULL")
return "(No game detected) ";
Expand Down Expand Up @@ -1553,8 +1555,8 @@ public static bool ShowCurrentHPPercentage()
return false;
}

public int currentMonster1MaxHP = 0;
public string currentMonster1HPPercent = "";
private int currentMonster1MaxHP = 0;
private string currentMonster1HPPercent = "";

/// <summary>
/// Gets the monster1 ehp percent.
Expand Down Expand Up @@ -1911,7 +1913,7 @@ public string GetQuestInformation()
return "";
case 21731://1st district dure
case 21749://sky corridor version
return "Slay 1st District Duremudira | "; ;
return "Slay 1st District Duremudira | ";
case 21746://2nd district dure
case 21750://sky corridor version
return "Slay 2nd District Duremudira | ";
Expand Down Expand Up @@ -1964,7 +1966,7 @@ public string GetRavienteEvent(int id)
/// <returns></returns>
public string GetQuestState()
{
if (DataLoader.isInLauncher) //works?
if (isInLauncherBool) //works?
return "";

switch (DataLoader.model.QuestState())
Expand Down Expand Up @@ -2015,7 +2017,7 @@ private void UpdateDiscordRPC()
return;
}

presenceTemplate.Details = string.Format("{0}{1}{2}{3}{4}{5}", GetPartySize(), GetQuestState(),GetCaravanScore(), GetOverlayMode(), GetAreaName(DataLoader.model.AreaID()), GetGameMode(DataLoader.isHighGradeEdition));
presenceTemplate.Details = string.Format("{0}{1}{2}{3}{4}{5}", GetPartySize(), GetQuestState(),GetCaravanScore(), GetOverlayMode(), GetAreaName(DataLoader.model.AreaID()), GetGameMode(DataLoader.IsHighGradeEdition));

//quest ids:
//mp road: 23527
Expand Down Expand Up @@ -2616,7 +2618,7 @@ private void OpenConfigButton_Key()
{
if (IsDragConfigure) return;

if (DataLoader.isInLauncher)
if (isInLauncherBool)
System.Windows.MessageBox.Show("Using the configuration menu outside of the game might cause slow performance", "Warning", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Warning);

if (configWindow == null || !configWindow.IsLoaded)
Expand Down
67 changes: 48 additions & 19 deletions MHFZ_Overlay/addresses/AddressModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ public abstract class AddressModel : INotifyPropertyChanged

public readonly Mem M;

public int SavedMonster1MaxHP = 0;
public int SavedMonster2MaxHP = 0;
private int SavedMonster1MaxHP = 0;
private int SavedMonster2MaxHP = 0;
private int SavedMonster3MaxHP = 0;
private int SavedMonster4MaxHP = 0;

Expand All @@ -33,9 +33,21 @@ public abstract class AddressModel : INotifyPropertyChanged

public AddressModel(Mem m) => M = m;

public int SelectedMonster = 0;
private int selectedMonster = 0;

public string SavedGearStats = "";
public int SelectedMonster
{
get { return selectedMonster; }
set { selectedMonster = value; }
}

private string savedGearStats = "";

public string SavedGearStats
{
get { return savedGearStats; }
set { savedGearStats = value; }
}

#endregion

Expand Down Expand Up @@ -675,7 +687,7 @@ public static string LoremImpsum
}
}

public bool _configuring = false;
private bool _configuring = false;

/// <summary>
/// Shows the monster ehp.
Expand Down Expand Up @@ -1071,9 +1083,9 @@ public string GetRoadTimerResetMode()
else return "Never";
}

public int MaxSharpness = 0;
private int MaxSharpness = 0;

public string TimeLeftPercent = "";
private string TimeLeftPercent = "";

public string TimeLeftPercentNumber
{
Expand Down Expand Up @@ -1177,7 +1189,19 @@ public string Time
}

//per quest
public int HighestAtk = 0;
private int highestAtk = 0;

public int HighestAtk
{
get
{
return highestAtk;
}
set
{
highestAtk = value;
}
}

/// <summary>
/// Shows the color of the highest atk.
Expand Down Expand Up @@ -1343,8 +1367,6 @@ public string AtkMult
}
}

public bool isMonsterFocused = false;

/// <summary>
/// Displays the monster ehp.
/// </summary>
Expand Down Expand Up @@ -1965,7 +1987,7 @@ public string getMonsterName(int id, bool isFirstMonster = true)
if (monstername != null && monstername != RealMonsterName && isFirstMonster)
return string.Format("{0}{1}", GetRankName(RankBand()), RealMonsterName);
else
return string.Format("{0}{1}", GetRankName(RankBand()), monstername); ;
return string.Format("{0}{1}", GetRankName(RankBand()), monstername);
}

#region monster hp
Expand Down Expand Up @@ -2279,11 +2301,8 @@ public string GetRealWeaponName
string className = GetWeaponClass();
string lv = GetWeaponNameFromType(WeaponType()).Contains("Bowgun") ? GetGRWeaponLevel(GRWeaponLvBowguns()) : GetGRWeaponLevel(GRWeaponLv());

if (GetTextFormat() == "Markdown")
{
if (lv == " Lv. 50" || lv == " Lv. 100")
lv = string.Format("**{0}**", lv);
}
if ((GetTextFormat() == "Markdown") && (lv == " Lv. 50" || lv == " Lv. 100"))
lv = string.Format("**{0}**", lv);

var style = WeaponStyle() switch
{
Expand Down Expand Up @@ -4106,7 +4125,19 @@ public static bool Is11GSR999()
return false;
}

public string MarkdownSavedGearStats = "";
private string markdownSavedGearStats = "";

public string MarkdownSavedGearStats
{
get
{
return markdownSavedGearStats;
}
set
{
markdownSavedGearStats = value;
}
}

/// <summary>
/// Determines whether [is fixed GSR skill value] [the specified skill name].
Expand Down Expand Up @@ -7100,8 +7131,6 @@ public static string GetGameRewardInfo
"※Attention\r\n・When Guild Poogie's \"Poogie Reward Technique\" is activated, the basic reward frame may exceed the upper limit and all 3 rows (24 frames) may become reward frames.\r\n・When a PT (2-4 people) of the same hunting party goes on a quest with different street name titles set for each other, the \"Street Name Title Skill (equivalent to Luck)\" will be activated with a certain probability. (Priority is given to the \"Great Luck\" skill.)\r\n・If you have a Super Lucky Charm, a Large Lucky Charm, or have purchased the Assist Course, it has the same effect as the Great Luck Skill.\r\n・Some quest rewards have fixed slots, in which case only the specified amount of reward slots will appear, regardless of luck skill, etc.\n\n" +
"●\u3000Obtaining Reward Materials\r\nOnce the number of frames has been determined, reward materials will be picked via RNG from a list according to the probability, and will be placed in order from the first frame.\r\nQuest rewards may have a fixed item, and always only the first slot will have a fixed item, not a RNG.\r\nFinally, each reward is sorted by item code.\r\nAdditional rewards for hunting HC Red Rajang, HC tickets and souls for each weapon will be added afterwards.\r\n\r\nIf you have the following charms, the number of materials obtained will be increased.\r\n・Super Lucky Charm:There is a 50% chance that the materials obtained will be doubled.\r\n・Large Lucky Charm:There is a 15% chance that the materials obtained will be doubled.\r\n\r\nThe \"Super Lucky Charm\" and the \"Large Lucky Charm\" can be used together. When they are used together, the \"Super Lucky Charm\" will activate the \"Super Luck\" skill, and then the \"Large Lucky Charm\" will activate the \"Great Luck\" skill.\r\n\r\n※Attention\r\n・In the case of practice quests, when \"no items\" is selected, the drawing ends there and no further drawings will be made.\r\n・Some quests have a fixed quota of rewards, in which case you only get the specified number of rewards, regardless of your charms, skills, etc.\n\n" +
"Daily Special\r\nThe following benefits are available once a day (updated at 12:00) in the \"Daily Special\" section of the General Shop.\r\nThe maximum N-point limit is 60,000 P. Others are overwritten each time they are received.\r\n\r\nN points\tTrial course: 1 point\r\nHunter Life Course: +3 points\r\nExtra course: +1 point\r\nPoint Bonus Rights\t3x\r\nGet Halk Pot\t5x\r\nDaily Quest Rights\t1x";
;

}
}

Expand Down
17 changes: 15 additions & 2 deletions MHFZ_Overlay/controls/CustomProgressBar.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,19 @@ public string CurrentHPPercentNumber
/// <summary>
/// The current hp percent
/// </summary>
public string CurrentHPPercent = "";
private string currentHPPercent = "";

public string CurrentHPPercent
{
get
{
return currentHPPercent;
}
set
{
currentHPPercent = value;
}
}

/// <summary>
/// Gets the descriptor horizontal alignment.
Expand Down Expand Up @@ -246,7 +258,8 @@ public float Value
/// </value>
public string Desc
{
get => Description; set => Description = value;
get { return Description; }
set { Description = value; }
}
#endregion
}
Expand Down

0 comments on commit 3546a4e

Please sign in to comment.