Skip to content

Commit

Permalink
feat: add watermark modes options
Browse files Browse the repository at this point in the history
closes #171
  • Loading branch information
DorielRivalet committed Aug 20, 2023
1 parent 12921bb commit c513fe7
Show file tree
Hide file tree
Showing 13 changed files with 281 additions and 127 deletions.
25 changes: 25 additions & 0 deletions MHFZOverlayBenchmark/Comparisons/TimerComparison.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,33 @@ namespace MHFZOverlayBenchmark.Comparisons;
using System.Text;
using System.Threading.Tasks;

[RPlotExporter]
[MedianColumn, MinColumn, MaxColumn]
[UnicodeConsoleLogger]
public class TimerComparison
{
[Params(0, 216_000)] // 2 hours at 30fps
public int TimeDefInt { get; set; }

[Params(0, 216_000)]
public int TimeInt { get; set; }

[Params(true, false)] // Arguments can be combined with Params
public bool TimePercentShown;

[Benchmark]
[Arguments(100, 10)]
[Arguments(100, 20)]
[Arguments(200, 10)]
[Arguments(200, 20)]
public void Benchmark(int a, int b)
{
if (TimePercentShown)
Thread.Sleep(a + b + 5);
else
Thread.Sleep(a + b);
}

private const int N = 10000;
private readonly byte[] data;

Expand Down
8 changes: 7 additions & 1 deletion MHFZ_Overlay/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -689,7 +689,7 @@
<value>180</value>
</setting>
<setting name="ShowDiscordRPCOverlayMode" serializeAs="String">
<value>True</value>
<value>False</value>
</setting>
<setting name="QuestAttemptsShown" serializeAs="String">
<value>False</value>
Expand Down Expand Up @@ -981,6 +981,12 @@
<setting name="VolumeGachaRare" serializeAs="String">
<value>1</value>
</setting>
<setting name="OverlayWatermarkMode" serializeAs="String">
<value>Final</value>
</setting>
<setting name="DiscordOverlayMode" serializeAs="String">
<value>Automatic</value>
</setting>
</MHFZ_Overlay.Settings>
</userSettings>
</configuration>
25 changes: 25 additions & 0 deletions MHFZ_Overlay/Models/Structures/Enums.cs
Original file line number Diff line number Diff line change
Expand Up @@ -415,3 +415,28 @@ public enum TimerFormat
MinutesSecondsMilliseconds,
HoursMinutesSeconds,
}

public enum OverlayMode
{
Unknown,
Standard,
Configuring,
ClosedGame,
Launcher,
NoGame,
MainMenu,
WorldSelect,
TimeAttack,
FreestyleSecretTech,
Freestyle,
Zen,
}

public enum ConfigurationPreset
{
None,
Speedrun,
Zen,
HPOnly,
All,
}
4 changes: 2 additions & 2 deletions MHFZ_Overlay/Services/AchievementService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2237,7 +2237,7 @@ join playerGear in databaseManagerInstance.AllPlayerGear on quest.RunID equals p
case 340:
return s.EnableRichPresence;
case 341:
if (dataLoader.Model.GetOverlayMode().Contains("Zen"))
if (dataLoader.Model.GetOverlayMode() == OverlayMode.Zen)
{
return true;
}
Expand All @@ -2247,7 +2247,7 @@ join playerGear in databaseManagerInstance.AllPlayerGear on quest.RunID equals p
}

case 342:
if (dataLoader.Model.GetOverlayMode().Contains("Freestyle"))
if (dataLoader.Model.GetOverlayMode() is OverlayMode.Freestyle or OverlayMode.FreestyleSecretTech )
{
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace MHFZ_Overlay.Services.Converter;

using MHFZ_Overlay.Models.Structures;
using static MHFZ_Overlay.Services.OverlaySettingsService;

public static class ConfigurationPresetConverter
Expand Down
7 changes: 4 additions & 3 deletions MHFZ_Overlay/Services/DatabaseService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -696,16 +696,16 @@ public void InsertPersonalBest(DataLoader dataLoader, long currentPersonalBest,

// check if its grabbing a TimeDefInt from a previous quest
// TODO is this enough?
if ((overlayModeDictionary.Count == 2 && overlayModeDictionary.Last().Value == string.Empty) ||
(overlayModeDictionary.Count == 1 && overlayModeDictionary.First().Value == string.Empty) ||
if ((overlayModeDictionary.Count == 2 && overlayModeDictionary.Last().Value == "Standard") ||
(overlayModeDictionary.Count == 1 && overlayModeDictionary.First().Value == "Standard") ||
overlayModeDictionary.Count > 2)
{
actualOverlayMode = "Standard";
}
else
{
// TODO: test
if (overlayModeDictionary.Count == 2 && overlayModeDictionary.First().Value == string.Empty)
if (overlayModeDictionary.Count == 2 && overlayModeDictionary.First().Value == "Standard")
{
actualOverlayMode = overlayModeDictionary.Last().Value;
}
Expand All @@ -714,6 +714,7 @@ public void InsertPersonalBest(DataLoader dataLoader, long currentPersonalBest,
actualOverlayMode = overlayModeDictionary.First().Value;
}

// TODO probably not needed anymore
actualOverlayMode = actualOverlayMode.Replace(")", string.Empty);
actualOverlayMode = actualOverlayMode.Replace("(", string.Empty);
actualOverlayMode = actualOverlayMode.Trim();
Expand Down
8 changes: 5 additions & 3 deletions MHFZ_Overlay/Services/DiscordService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ namespace MHFZ_Overlay.Services;
using System;
using System.Diagnostics;
using System.Globalization;
using System.Windows;
using DiscordRPC;
using EZlion.Mapper;
using MHFZ_Overlay;
using MHFZ_Overlay.Models.Collections;
using MHFZ_Overlay.Models.Constant;
using MHFZ_Overlay.Models.Structures;

/// <summary>
/// Handles the Discord Rich Presence. Should not operate if the user is not enabling it.
Expand Down Expand Up @@ -216,13 +218,13 @@ public void UpdateDiscordRPC(DataLoader dataLoader)
}

// TODO also need to handle the other fields lengths
if (string.Format(CultureInfo.InvariantCulture, "{0}{1}{2}{3}{4}{5}", this.GetPartySize(dataLoader), GetQuestState(dataLoader), GetCaravanScore(dataLoader), dataLoader.Model.GetOverlayModeForRPC(), dataLoader.Model.GetAreaName(dataLoader.Model.AreaID()), GetGameMode(dataLoader.IsHighGradeEdition)).Length >= 95)
if (string.Format(CultureInfo.InvariantCulture, "{0}{1}{2}{3}{4}{5}", dataLoader.Model.GetOverlayModeForRPC(), this.GetPartySize(dataLoader), GetQuestState(dataLoader), GetCaravanScore(dataLoader), dataLoader.Model.GetAreaName(dataLoader.Model.AreaID()), GetGameMode(dataLoader.IsHighGradeEdition)).Length >= 95)
{
PresenceTemplate.Details = string.Format(CultureInfo.InvariantCulture, "{0}{1}{2}", GetQuestState(dataLoader), dataLoader.Model.GetOverlayModeForRPC(), dataLoader.Model.GetAreaName(dataLoader.Model.AreaID()));
PresenceTemplate.Details = string.Format(CultureInfo.InvariantCulture, "{0}{1}{2}", dataLoader.Model.GetOverlayModeForRPC(), GetQuestState(dataLoader), dataLoader.Model.GetAreaName(dataLoader.Model.AreaID()));
}
else
{
PresenceTemplate.Details = string.Format(CultureInfo.InvariantCulture, "{0}{1}{2}{3}{4}{5}", this.GetPartySize(dataLoader), GetQuestState(dataLoader), GetCaravanScore(dataLoader), dataLoader.Model.GetOverlayModeForRPC(), dataLoader.Model.GetAreaName(dataLoader.Model.AreaID()), GetGameMode(dataLoader.IsHighGradeEdition));
PresenceTemplate.Details = string.Format(CultureInfo.InvariantCulture, "{0}{1}{2}{3}{4}{5}", dataLoader.Model.GetOverlayModeForRPC(), this.GetPartySize(dataLoader), GetQuestState(dataLoader), GetCaravanScore(dataLoader), dataLoader.Model.GetAreaName(dataLoader.Model.AreaID()), GetGameMode(dataLoader.IsHighGradeEdition));
}

var stateString = string.Empty;
Expand Down
10 changes: 1 addition & 9 deletions MHFZ_Overlay/Services/OverlaySettingsService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ namespace MHFZ_Overlay.Services;
using System.Diagnostics;
using System.Globalization;
using MHFZ_Overlay;
using MHFZ_Overlay.Models.Structures;

public sealed class OverlaySettingsService
{
Expand All @@ -16,15 +17,6 @@ public sealed class OverlaySettingsService

private OverlaySettingsService() => Logger.Info($"Service initialized");

public enum ConfigurationPreset
{
None,
Speedrun,
Zen,
HPOnly,
All,
}

public static OverlaySettingsService GetInstance()
{
if (instance == null)
Expand Down
28 changes: 26 additions & 2 deletions MHFZ_Overlay/Settings.Designer.cs

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

8 changes: 7 additions & 1 deletion MHFZ_Overlay/Settings.settings
Original file line number Diff line number Diff line change
Expand Up @@ -684,7 +684,7 @@
<Value Profile="(Default)">180</Value>
</Setting>
<Setting Name="ShowDiscordRPCOverlayMode" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">True</Value>
<Value Profile="(Default)">False</Value>
</Setting>
<Setting Name="QuestAttemptsShown" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
Expand Down Expand Up @@ -974,5 +974,11 @@
<Setting Name="VolumeGachaRare" Type="System.Single" Scope="User">
<Value Profile="(Default)">1</Value>
</Setting>
<Setting Name="OverlayWatermarkMode" Type="System.String" Scope="User">
<Value Profile="(Default)">Final</Value>
</Setting>
<Setting Name="DiscordOverlayMode" Type="System.String" Scope="User">
<Value Profile="(Default)">Automatic</Value>
</Setting>
</Settings>
</SettingsFile>
Loading

0 comments on commit c513fe7

Please sign in to comment.