Skip to content

Commit

Permalink
[feat] Search Available | [fix] Give Button ID | [chore] Use Dalamud.…
Browse files Browse the repository at this point in the history
…NET.SDK
  • Loading branch information
DueDine committed Dec 18, 2024
1 parent a4c1e36 commit 1c6cc8d
Show file tree
Hide file tree
Showing 4 changed files with 106 additions and 13 deletions.
5 changes: 2 additions & 3 deletions ContactsTracker/ContactsTracker.csproj
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="Dalamud.Plugin.Bootstrap.targets" />
<Project Sdk="Dalamud.NET.SDK/11.0.0">

<PropertyGroup>
<TargetFramework>net8.0-windows</TargetFramework>
<Version>0.0.2.0</Version>
<Version>0.1.0.0</Version>
<Description>Help you remember previous contacts.</Description>
<PackageProjectUrl>https://github.com/DueDine/ContactsTracker</PackageProjectUrl>
<PackageLicenseExpression>AGPL-3.0-or-later</PackageLicenseExpression>
Expand Down
11 changes: 5 additions & 6 deletions ContactsTracker/Windows/AnalyzeWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public class AnalyzeWindow : Window, IDisposable
{
if (TimeSpan.TryParse(entry.beginAt, out var beginAt) && TimeSpan.TryParse(entry.endAt, out var endAt))
{
if (endAt < beginAt)
if (endAt < beginAt) // If the roulette ends on the next day
{
endAt = endAt.Add(TimeSpan.FromDays(1));
}
Expand Down Expand Up @@ -80,7 +80,6 @@ public void Dispose() { }

public override void Draw()
{
// ImGui.Text("Some query will take a while to complete, please be patient.");
ImGui.Text("If you have a suggestion for a new query, please let me know.");

if (ImGui.CollapsingHeader("Top X pair of Roulette and Map"))
Expand All @@ -93,13 +92,13 @@ public override void Draw()
topXState.IsClicked = false;
}
ImGui.SameLine();
if (ImGui.Button("Query"))
if (ImGui.Button("Query##Q1"))
{
topXState.IsClicked = true;
topXState.IsAvailable = false;
}
ImGui.SameLine();
if (ImGui.Button("Reset"))
if (ImGui.Button("Reset##R1"))
{
topX = 0;
topXState.IsClicked = false;
Expand Down Expand Up @@ -153,13 +152,13 @@ public override void Draw()

if (ImGui.CollapsingHeader("How much time for each roulette"))
{
if (ImGui.Button("Query"))
if (ImGui.Button("Query##Q2"))
{
totalDurationState.IsClicked = true;
totalDurationState.IsAvailable = false;
}
ImGui.SameLine();
if (ImGui.Button("Reset"))
if (ImGui.Button("Reset##R2"))
{
totalDurationState.IsClicked = false;
totalDurationState.IsAvailable = false;
Expand Down
45 changes: 41 additions & 4 deletions ContactsTracker/Windows/MainWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ public class MainWindow : Window, IDisposable
{
private Plugin Plugin;
private int selectedTab = 0;
private string commentBuffer = string.Empty;
// private string commentBuffer = string.Empty;
private bool isFileDialogOpen = false;
private bool doubleCheck = false;
private bool enableSearch = false;
private string searchBuffer = string.Empty;

public MainWindow(Plugin plugin)
: base("Contacts Tracker", ImGuiWindowFlags.NoScrollbar | ImGuiWindowFlags.NoScrollWithMouse)
Expand Down Expand Up @@ -125,14 +127,49 @@ private void DrawActiveTab()

}

// TODO: Filter / Search by any field
private void DrawHistoryTab()
{

var entries = Database.Entries;

if (ImGui.Button("Enable / Disable Search Feature"))
{
enableSearch = !enableSearch;
}

if (enableSearch)
{
ImGui.Spacing();
if (ImGui.InputText("Search", ref searchBuffer, 50))
{
selectedTab = 0; // Avoid out of range
}
ImGui.Spacing();
if (!string.IsNullOrEmpty(searchBuffer))
{
entries = entries
.Where(entry =>
(entry.TerritoryName?.Contains(searchBuffer, StringComparison.OrdinalIgnoreCase) ?? false) ||
(entry.RouletteType?.Contains(searchBuffer, StringComparison.OrdinalIgnoreCase) ?? false) ||
(entry.Date?.Contains(searchBuffer, StringComparison.OrdinalIgnoreCase) ?? false) ||
(entry.beginAt?.Contains(searchBuffer, StringComparison.OrdinalIgnoreCase) ?? false) ||
(entry.endAt?.Contains(searchBuffer, StringComparison.OrdinalIgnoreCase) ?? false) ||
(entry.jobName?.Contains(searchBuffer, StringComparison.OrdinalIgnoreCase) ?? false) ||
(entry.partyMembers?.Contains(searchBuffer, StringComparison.OrdinalIgnoreCase) ?? false) ||
(entry.comment?.Contains(searchBuffer, StringComparison.OrdinalIgnoreCase) ?? false)
).ToList();
}
}

if (entries.Count == 0)
{
ImGui.Text("No record yet.");
if (enableSearch)
{
ImGui.Text("No record found.");
}
else
{
ImGui.Text("No record yet.");
}
return;
}

Expand Down
58 changes: 58 additions & 0 deletions ContactsTracker/packages.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,64 @@
"requested": "[11.0.0, )",
"resolved": "11.0.0",
"contentHash": "bjT7XUlhIJSmsE/O76b7weUX+evvGQctbQB8aKXt94o+oPWxHpCepxAGMs7Thow3AzCyqWs7cOpp9/2wcgRRQA=="
},
"DotNet.ReproducibleBuilds": {
"type": "Direct",
"requested": "[1.1.1, )",
"resolved": "1.1.1",
"contentHash": "+H2t/t34h6mhEoUvHi8yGXyuZ2GjSovcGYehJrS2MDm2XgmPfZL2Sdxg+uL2lKgZ4M6tTwKHIlxOob2bgh0NRQ==",
"dependencies": {
"Microsoft.SourceLink.AzureRepos.Git": "1.1.1",
"Microsoft.SourceLink.Bitbucket.Git": "1.1.1",
"Microsoft.SourceLink.GitHub": "1.1.1",
"Microsoft.SourceLink.GitLab": "1.1.1"
}
},
"Microsoft.Build.Tasks.Git": {
"type": "Transitive",
"resolved": "1.1.1",
"contentHash": "AT3HlgTjsqHnWpBHSNeR0KxbLZD7bztlZVj7I8vgeYG9SYqbeFGh0TM/KVtC6fg53nrWHl3VfZFvb5BiQFcY6Q=="
},
"Microsoft.SourceLink.AzureRepos.Git": {
"type": "Transitive",
"resolved": "1.1.1",
"contentHash": "qB5urvw9LO2bG3eVAkuL+2ughxz2rR7aYgm2iyrB8Rlk9cp2ndvGRCvehk3rNIhRuNtQaeKwctOl1KvWiklv5w==",
"dependencies": {
"Microsoft.Build.Tasks.Git": "1.1.1",
"Microsoft.SourceLink.Common": "1.1.1"
}
},
"Microsoft.SourceLink.Bitbucket.Git": {
"type": "Transitive",
"resolved": "1.1.1",
"contentHash": "cDzxXwlyWpLWaH0em4Idj0H3AmVo3L/6xRXKssYemx+7W52iNskj/SQ4FOmfCb8YQt39otTDNMveCZzYtMoucQ==",
"dependencies": {
"Microsoft.Build.Tasks.Git": "1.1.1",
"Microsoft.SourceLink.Common": "1.1.1"
}
},
"Microsoft.SourceLink.Common": {
"type": "Transitive",
"resolved": "1.1.1",
"contentHash": "WMcGpWKrmJmzrNeuaEb23bEMnbtR/vLmvZtkAP5qWu7vQsY59GqfRJd65sFpBszbd2k/bQ8cs8eWawQKAabkVg=="
},
"Microsoft.SourceLink.GitHub": {
"type": "Transitive",
"resolved": "1.1.1",
"contentHash": "IaJGnOv/M7UQjRJks7B6p7pbPnOwisYGOIzqCz5ilGFTApZ3ktOR+6zJ12ZRPInulBmdAf1SrGdDG2MU8g6XTw==",
"dependencies": {
"Microsoft.Build.Tasks.Git": "1.1.1",
"Microsoft.SourceLink.Common": "1.1.1"
}
},
"Microsoft.SourceLink.GitLab": {
"type": "Transitive",
"resolved": "1.1.1",
"contentHash": "tvsg47DDLqqedlPeYVE2lmiTpND8F0hkrealQ5hYltSmvruy/Gr5nHAKSsjyw5L3NeM/HLMI5ORv7on/M4qyZw==",
"dependencies": {
"Microsoft.Build.Tasks.Git": "1.1.1",
"Microsoft.SourceLink.Common": "1.1.1"
}
}
}
}
Expand Down

0 comments on commit 1c6cc8d

Please sign in to comment.