Skip to content

Commit

Permalink
update for better looks
Browse files Browse the repository at this point in the history
  • Loading branch information
edg-l committed Feb 19, 2023
1 parent 77f77f2 commit 2d14a85
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 86 deletions.
2 changes: 1 addition & 1 deletion PartyPlanner/PartyPlanner.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<Authors>Zhyra</Authors>
<Company></Company>
<Version>1.4.4</Version>
<Version>1.5.0</Version>
<Description>PartyVerse.app, directly on your client!</Description>
<Copyright>MIT</Copyright>
<PackageProjectUrl>https://github.com/edg-l/PartyPlanner</PackageProjectUrl>
Expand Down
122 changes: 37 additions & 85 deletions PartyPlanner/PluginUI.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Dalamud.Logging;
using Dalamud.Utility;
using Humanizer;
using ImGuiNET;
using System;
Expand All @@ -21,10 +22,10 @@ class PluginUI : IDisposable
private PartyVerseApi partyVerseApi { get; init; }
// All the events
private readonly List<Models.EventType> partyVerseEvents = new(50);
private string filterTag;
private string windowTitle;
private readonly Dictionary<int, List<Models.EventType>> eventsByDc = new();
private readonly Dictionary<int, SortedDictionary<string, bool>> tagsByDc = new();
private DateTime lastUpdate = DateTime.Now;

// this extra bool exists for ImGui, since you can't ref a property
private bool visible = false;
Expand All @@ -40,14 +41,12 @@ public bool EventDetailsOpen
get { return this.eventDetailsOpen; }
set { this.eventDetailsOpen = value; }
}
private Models.EventType? eventDetails = null;

public PluginUI(Configuration configuration)
{
this.configuration = configuration;
this.partyVerseApi = new PartyVerseApi();
windowTitle = "PartyPlanner";
filterTag = "";

try
{
Expand All @@ -70,7 +69,6 @@ public void Dispose()
public void Draw()
{
DrawMainWindow();
DrawEventWindow();
}

public async void UpdateEvents()
Expand All @@ -80,6 +78,7 @@ public async void UpdateEvents()
tagsByDc.Clear();
partyVerseEvents.AddRange(await this.partyVerseApi.GetActiveEvents());
partyVerseEvents.AddRange(await this.partyVerseApi.GetEvents());
lastUpdate = DateTime.Now;
foreach (var ev in partyVerseEvents)
{
var key = ev.LocationData.DataCenter.Id;
Expand All @@ -90,7 +89,7 @@ public async void UpdateEvents()
if (!tagsByDc.ContainsKey(key))
tagsByDc.Add(key, new());

foreach(var tag in ev.Tags)
foreach (var tag in ev.Tags)
{
if (!tagsByDc[key].ContainsKey(tag))
tagsByDc[key].Add(tag, false);
Expand All @@ -108,6 +107,8 @@ public void DrawMainWindow()
{
if (ImGui.Button("Reload Events"))
Task.Run(UpdateEvents);
ImGui.SameLine();
ImGui.Text(string.Format("Updated {0}", lastUpdate.Humanize()));

ImGui.Spacing();

Expand Down Expand Up @@ -162,140 +163,91 @@ public void DrawDataCenter(Models.DataCenterType dataCenter)
}
}

ImGui.Spacing();

if (ImGui.BeginTable(string.Format("partyverse_events_{0}", dataCenter.Name), 5,
ImGuiTableFlags.RowBg | ImGuiTableFlags.Borders | ImGuiTableFlags.BordersInner))
foreach (var ev in events)
{
ImGui.TableHeader("Events");
ImGui.TableSetupColumn("Title (click for more info)", ImGuiTableColumnFlags.WidthFixed);
ImGui.TableSetupColumn("Location", ImGuiTableColumnFlags.WidthFixed);
ImGui.TableSetupColumn("Description", ImGuiTableColumnFlags.WidthStretch);
ImGui.TableSetupColumn("Starts", ImGuiTableColumnFlags.WidthFixed);
ImGui.TableSetupColumn("Ends", ImGuiTableColumnFlags.WidthFixed);
ImGui.TableHeadersRow();
ImGui.TableNextRow();

foreach (var ev in events)
bool filtered = false;
foreach (var (tag, selected) in tags)
{
bool filtered = false;
foreach(var (tag, selected) in tags)
if (selected && !ev.Tags.Contains(tag))
{
if(selected && !ev.Tags.Contains(tag))
{
filtered = true;
break;
}
filtered = true;
break;
}
}

if(!filtered)
{
DrawEventRow(ev);
}

if (!filtered)
{
ImGui.Separator();
ImGui.PushID(ev.Id);
DrawEventRow(ev);
ImGui.PopID();
}

ImGui.EndTable();
}
ImGui.EndTabItem();
}
}

public void DrawEventRow(Models.EventType ev)
{
ImGui.TableNextColumn();

ImGui.Spacing();

var greenColor = new Vector4(0.0742f, 0.530f, 0.150f, 1.0f);

var title = ev.Title;
if (title.Length > 30)
title = title[..30] + "...";

if (ImGui.Button(title))
ImGui.TextColored(new Vector4(0.668f, 0.146f, 0.910f, 1.0f), ev.Title);
if (ImGui.IsItemClicked())
{
this.eventDetails = ev;
EventDetailsOpen = true;
Util.OpenLink("https://www.partake.gg/events/{0}".Format(ev.Id));
}

if (ImGui.IsItemHovered())
{
ImGui.BeginTooltip();
ImGui.TextColored(greenColor, ev.Title);
ImGui.Text("Click to open a detailed view.");
ImGui.Text("Click to open the partake.gg website.");
ImGui.EndTooltip();
}

string description = ev.Description;

if (description.Length > 200)
description = description[..200] + "...";

ImGui.TableNextColumn();


var originalLocation = string.Format("[{0}] {1}", ev.LocationData.Server.Name, ev.Location);
var location = originalLocation;
if (location.Length > 100)
location = location[..100] + "...";

ImGui.Text("Location:");
ImGui.SameLine();
var location = string.Format("[{0}] {1}", ev.LocationData.Server.Name, ev.Location);
if (ImGui.Selectable(location))
{
ImGui.SetClipboardText(originalLocation);
ImGui.SetClipboardText(location);
}

if (ImGui.IsItemHovered())
{
ImGui.BeginTooltip();
ImGui.TextColored(greenColor, originalLocation);
ImGui.TextColored(greenColor, location);
ImGui.Text("Click to copy");
ImGui.EndTooltip();
}

var startsAt = ev.StartsAt.ToLocalTime();
var endsAt = ev.EndsAt.ToLocalTime();

ImGui.TableNextColumn();
ImGui.TextWrapped(description);
ImGui.TableNextColumn();
ImGui.Text(ev.StartsAt.Humanize());
ImGui.Text(string.Format("Starts {0}", ev.StartsAt.Humanize()));
if (ImGui.IsItemHovered())
{
ImGui.BeginTooltip();
ImGui.SetTooltip(startsAt.ToString());
ImGui.EndTooltip();
}
ImGui.TableNextColumn();
ImGui.Text(endsAt.Humanize());
ImGui.SameLine();
ImGui.Text(string.Format("| Ends {0}", ev.EndsAt.Humanize()));
if (ImGui.IsItemHovered())
{
ImGui.BeginTooltip();
ImGui.SetTooltip(endsAt.ToString());
ImGui.EndTooltip();
}
ImGui.TableNextRow();
}
ImGui.TextColored(new Vector4(0.156f, 0.665f, 0.920f, 1.0f),
string.Format("From {0} to {1}", ev.StartsAt.ToLocalTime().ToString(), ev.EndsAt.ToLocalTime().ToString()));

public void DrawEventWindow()
{
if (!EventDetailsOpen || this.eventDetails == null)
{
return;
}
ImGui.TextColored(new Vector4(0.0888f, 0.740f, 0.176f, 1.0f),
string.Format("Tags: {0}", string.Join(", ", ev.Tags)));

ImGui.SetNextWindowSizeConstraints(new Vector2(300, 100), new Vector2(800, 800));
if (ImGui.Begin(string.Format("{0}", eventDetails.Title), ref this.eventDetailsOpen, ImGuiWindowFlags.NoCollapse | ImGuiWindowFlags.AlwaysAutoResize))
if (ImGui.CollapsingHeader("More details"))
{
ImGui.TextWrapped(eventDetails.Description);
ImGui.Spacing();
ImGui.TextColored(new Vector4(0.668f, 0.146f, 0.910f, 1.0f), eventDetails.Location);
ImGui.Spacing();
ImGui.TextColored(new Vector4(0.156f, 0.665f, 0.920f, 1.0f),
string.Format("From {0} to {1}", eventDetails.StartsAt.ToLocalTime().ToString(), eventDetails.EndsAt.ToLocalTime().ToString()));
ImGui.Spacing();
ImGui.TextColored(new Vector4(0.0888f, 0.740f, 0.176f, 1.0f),
string.Format("Tags: {0}", string.Join(", ", eventDetails.Tags)));
ImGui.TextWrapped(ev.Description);
}
}
}
Expand Down

0 comments on commit 2d14a85

Please sign in to comment.