Skip to content

Commit

Permalink
feat: add roll reminder
Browse files Browse the repository at this point in the history
  • Loading branch information
kalilistic committed Sep 22, 2021
1 parent 735fab6 commit f075ff5
Show file tree
Hide file tree
Showing 9 changed files with 133 additions and 28 deletions.
1 change: 1 addition & 0 deletions src/Kapture.Test/Kapture.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Dalamud.DrunkenToad" Version="1.1.3" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.1" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
Expand Down
1 change: 0 additions & 1 deletion src/Kapture.Test/Mocks/KapturePluginMock.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Collections.Generic;
using Dalamud.DrunkenToad;
using Dalamud.Game.ClientState.Party;
using Dalamud.Game.Text;

Expand Down
2 changes: 1 addition & 1 deletion src/Kapture/Kapture.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
<ItemGroup>
<PackageReference Include="ILRepack" Version="2.0.18" />
<PackageReference Include="DalamudPackager" Version="2.1.2" />
<PackageReference Include="Dalamud.DrunkenToad" Version="1.1.2" />
<PackageReference Include="Dalamud.DrunkenToad" Version="1.1.3" />
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
18 changes: 18 additions & 0 deletions src/Kapture/Kapture/Model/ItemList.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
namespace Kapture
{
/// <summary>
/// Item list.
/// </summary>
public class ItemList
{
/// <summary>
/// Gets item ids.
/// </summary>
public uint[] ItemIds { get; init; } = null!;

/// <summary>
/// Gets item names.
/// </summary>
public string[] ItemNames { get; init; } = null!;
}
}
10 changes: 10 additions & 0 deletions src/Kapture/Kapture/Model/LootRoller.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,15 @@ public class LootRoller
/// Gets or sets a value indicating whether is winner.
/// </summary>
public bool IsWinner { get; set; }

/// <summary>
/// Gets or sets a value indicating whether alert roll has been made.
/// </summary>
public bool IsReminderSent { get; set; }

/// <summary>
/// Gets a value indicating whether is local player.
/// </summary>
public bool IsLocalPlayer { get; init; }
}
}
10 changes: 10 additions & 0 deletions src/Kapture/Kapture/Plugin/Configuration/KaptureConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -206,5 +206,15 @@ public class KaptureConfig : IPluginConfiguration

/// <inheritdoc />
public int Version { get; set; }

/// <summary>
/// Gets or sets a value indicating whether gets or sets a value indicating to send alert.
/// </summary>
public bool SendRollReminder { get; set; } = true;

/// <summary>
/// Gets or sets the time in ms for alert warning.
/// </summary>
public int RollReminderTime { get; set; } = 15000;
}
}
66 changes: 41 additions & 25 deletions src/Kapture/Kapture/Resource/source/Kapture_Localizable.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,45 +7,57 @@
"message": "Use /loot and /roll for the overlays and /lootconfig for settings.",
"description": "KapturePlugin.HandleFreshInstall"
},
"WatchListAddedAlert": {
"message": "{0} dropped and is on your watch list.",
"description": "RollMonitor.ProcessRoll"
},
"WatchListObtainedAlert": {
"message": "{0} obtained so removing from your watch list.",
"description": "RollMonitor.ProcessRoll"
},
"RollMonitorLost": {
"message": "Dropped to floor",
"description": "RollMonitor.ProcessRoll"
},
"RollReminder": {
"message": "Roll soon on {0}!",
"description": "RollMonitor.SendRollReminder"
},
"LootOverlayWindow": {
"message": "Loot",
"description": "LootOverlayWindow.DrawView"
"description": "LootWindow..ctor"
},
"LootItemName": {
"message": "Item",
"description": "LootOverlayWindow.DrawView"
"description": "LootWindow.Draw"
},
"LootEventType": {
"message": "Event",
"description": "LootOverlayWindow.DrawView"
"description": "LootWindow.Draw"
},
"LootPlayer": {
"message": "Player",
"description": "LootOverlayWindow.DrawView"
"description": "LootWindow.Draw"
},
"WaitingForItems": {
"message": "Waiting for items.",
"description": "LootOverlayWindow.DrawView"
"description": "LootWindow.Draw"
},
"RollMonitorOverlayWindow": {
"message": "Roll Monitor",
"description": "RollMonitorOverlay.DrawView"
"description": "RollWindow..ctor"
},
"MonitorItemName": {
"message": "Item",
"description": "RollMonitorOverlay.DrawView"
"description": "RollWindow.Draw"
},
"MonitorRollers": {
"message": "Rollers",
"description": "RollMonitorOverlay.DrawView"
"description": "RollWindow.Draw"
},
"MonitorWinner": {
"message": "Winner",
"description": "RollMonitorOverlay.DrawView"
},
"SettingsWindow": {
"message": "Kapture Settings",
"description": "SettingsWindow.DrawView"
"description": "RollWindow.Draw"
},
"General": {
"message": "General",
Expand Down Expand Up @@ -131,6 +143,14 @@
"message": "show roll monitor overlay window",
"description": "SettingsWindow.DrawRolls"
},
"ShowRollReminder": {
"message": "Show Roll Reminder in Chat",
"description": "SettingsWindow.DrawRolls"
},
"ShowRollReminder_HelpMarker": {
"message": "send roll reminder before item drops",
"description": "SettingsWindow.DrawRolls"
},
"RollDisplayMode": {
"message": "Display Mode",
"description": "SettingsWindow.DrawRolls"
Expand Down Expand Up @@ -163,6 +183,14 @@
"message": "amount of time before removing obtained/lost items from roll monitor",
"description": "SettingsWindow.DrawRolls"
},
"RollReminderTime": {
"message": "Roll Reminder Warning (seconds)",
"description": "SettingsWindow.DrawRolls"
},
"RollReminderTime_HelpMarker": {
"message": "amount of time in advanced of missing roll to send reminder",
"description": "SettingsWindow.DrawRolls"
},
"AddEnabled": {
"message": "Add",
"description": "SettingsWindow.DrawEventTypes"
Expand Down Expand Up @@ -326,17 +354,5 @@
"ClearData": {
"message": "Clear Data",
"description": "SettingsWindow.DrawLinks"
},
"WatchListAddedAlert": {
"message": "{0} dropped and is on your watch list.",
"description": "RollMonitor.ProcessRoll"
},
"WatchListObtainedAlert": {
"message": "{0} obtained so removing from your watch list.",
"description": "RollMonitor.ProcessRoll"
},
"RollMonitorLost": {
"message": "Dropped to floor",
"description": "RollMonitor.ProcessRoll"
}
}
19 changes: 19 additions & 0 deletions src/Kapture/Kapture/Service/RollMonitor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ public void UpdateRolls()
this.plugin.Configuration.RollMonitorObtainedTimeout);
this.plugin.IsRolling = this.plugin.LootRolls.Count > 0;
this.CreateDisplayList();
this.SendRollReminder();
}
catch (Exception ex)
{
Expand Down Expand Up @@ -103,6 +104,7 @@ public void ProcessRoll(LootEvent lootEvent)
this.plugin.Configuration.RollNameFormat,
player.Name.ToString()),
RollColor = ImGuiColorUtil.GetColorByNumber(0),
IsLocalPlayer = player.ObjectId == KapturePlugin.ClientState.LocalPlayer?.ObjectId,
});
}

Expand Down Expand Up @@ -260,5 +262,22 @@ private void CreateDisplayList()
this.plugin.LootRollsDisplay =
JsonConvert.DeserializeObject<List<LootRoll>>(JsonConvert.SerializeObject(this.plugin.LootRolls));
}

private void SendRollReminder()
{
if (!this.plugin.Configuration.SendRollReminder) return;
foreach (var lootRoll in this.plugin.LootRolls.Where(roll => !roll.IsWon))
{
var rollerMatch = lootRoll.Rollers.FirstOrDefault(roller =>
roller.IsLocalPlayer &&
!roller.HasRolled && !roller.IsReminderSent &&
DateUtil.CurrentTime() > lootRoll.Timestamp + 300000 - this.plugin.Configuration.RollReminderTime);
if (rollerMatch != null)
{
rollerMatch.IsReminderSent = true;
KapturePlugin.Chat.PluginPrintNotice(string.Format(Loc.Localize("RollReminder", "Roll soon on {0}!"), lootRoll.ItemName));
}
}
}
}
}
34 changes: 33 additions & 1 deletion src/Kapture/Kapture/UserInterface/SettingsWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ private enum Tab
/// <inheritdoc />
public override void Draw()
{
ImGui.SetNextWindowSize(new Vector2(500 * ImGuiHelpers.GlobalScale, 320 * ImGuiHelpers.GlobalScale), ImGuiCond.Appearing);
ImGui.SetNextWindowSize(new Vector2(500 * ImGuiHelpers.GlobalScale, 360 * ImGuiHelpers.GlobalScale), ImGuiCond.Appearing);
this.DrawTabs();
switch (this.currentTab)
{
Expand Down Expand Up @@ -271,6 +271,22 @@ private void DrawRolls()
"show roll monitor overlay window"));
ImGui.Spacing();

// show roll reminder
var showRollReminder = this.plugin.Configuration.SendRollReminder;
if (ImGui.Checkbox(
Loc.Localize("ShowRollReminder", "Show Roll Reminder in Chat") + "###Kapture_ShowRollReminder_Checkbox",
ref showRollReminder))
{
this.plugin.Configuration.ShowRollMonitorOverlay = showRollReminder;
this.Plugin.WindowManager.RollWindow!.IsOpen = showRollReminder;
this.plugin.SaveConfig();
}

ImGuiComponents.HelpMarker(Loc.Localize(
"ShowRollReminder_HelpMarker",
"send roll reminder before item drops"));
ImGui.Spacing();

// display mode
ImGui.Text(Loc.Localize("RollDisplayMode", "Display Mode"));
ImGuiComponents.HelpMarker(Loc.Localize(
Expand Down Expand Up @@ -340,6 +356,22 @@ private void DrawRolls()
}

ImGui.Spacing();

// roll reminder warning
ImGui.Text(Loc.Localize("RollReminderTime", "Roll Reminder Warning (seconds)"));
ImGuiComponents.HelpMarker(Loc.Localize(
"RollReminderTime_HelpMarker",
"amount of time in advanced of missing roll to send reminder"));
var rollReminderTime =
this.plugin.Configuration.RollReminderTime.FromMillisecondsToSeconds();
if (ImGui.SliderInt("###PlayerTrack_RollReminderTime_Slider", ref rollReminderTime, 5, 60))
{
this.plugin.Configuration.RollReminderTime =
rollReminderTime.FromSecondsToMilliseconds();
this.plugin.SaveConfig();
}

ImGui.Spacing();
}

private void DrawEventTypes()
Expand Down

0 comments on commit f075ff5

Please sign in to comment.