15 Commits

Author SHA1 Message Date
2aae676fa3 Update .github/workflows/release.yml
All checks were successful
Build and Release / Build (push) Successful in 23s
2025-12-19 06:06:10 +01:00
e9e6937794 Merge branch 'main' of ssh://gitea.lozy.pink:22222/lozy360/spotify-honorific
Some checks failed
Build and Release / Build (push) Failing after 25s
2025-12-19 06:59:10 +02:00
abd7e2515f Update Dalamud SDK and Packager to v14.0.1
Upgraded Dalamud.NET.Sdk and DalamudPackager from version 14.0.0 to 14.0.1 in the project file and package lock. No other dependencies were changed.
2025-12-19 06:58:58 +02:00
14980a9ec4 Update .github/workflows/release.yml 2025-12-19 05:57:31 +01:00
e9d0a2b606 Update .github/workflows/build.yml 2025-12-19 05:57:09 +01:00
885119dc47 yes
All checks were successful
Build and Release / Build (push) Successful in 24s
2025-12-18 10:19:45 +02:00
6f825ec210 Update to 7.4 build dalamud
Some checks failed
Build and Release / Build (push) Failing after 23s
2025-12-18 10:09:07 +02:00
6578f83dd8 Update to 7.4
Some checks failed
Build and Release / Build (push) Failing after 13s
2025-12-18 10:03:45 +02:00
cd23b9e381 yes 2025-08-06 17:01:25 +03:00
f299e04189 Upgrade 13 2025-08-06 17:01:08 +03:00
023418599e api13 2025-08-06 16:53:14 +03:00
b124838915 test 2025-08-06 15:58:06 +03:00
726ecc5688 Fixing readme 2025-06-24 18:10:16 +03:00
561811cd1f Enhance command handling and add namespace imports
- Added `using` directives for essential namespaces in `Plugin.cs`.
- Implemented a "set" subcommand for configuring activity options, including color and prefix/suffix settings.
- Added error handling for duplicate and invalid inputs, with user feedback via chat.
- Updated the configuration for the first activity based on user input.
2025-06-22 21:44:51 +03:00
0c0c72be9f Enhance Spotify track retrieval in Updater.cs
Updated `Updater.cs` to improve functionality for retrieving the currently playing track in Spotify. Added new methods for window title retrieval and utilized the `EnumWindows` function to filter and identify relevant Spotify track titles. Included P/Invoke declarations for Windows API functions to support these enhancements, along with a new method `GetWindowTitle` for better code organization.
2025-06-11 20:39:08 +03:00
9 changed files with 164 additions and 31 deletions

View File

@@ -18,11 +18,11 @@ jobs:
- name: Set up .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 9.0.x
dotnet-version: 10.0.x
- name: Download Dalamud Latest
run: |
wget https://goatcorp.github.io/dalamud-distrib/latest.zip -O ${{ env.DALAMUD_HOME }}.zip
wget https://goatcorp.github.io/dalamud-distrib/stg/latest.zip -O ${{ env.DALAMUD_HOME }}.zip
unzip ${{ env.DALAMUD_HOME }}.zip -d ${{ env.DALAMUD_HOME }}
- name: Restore Project

View File

@@ -17,11 +17,11 @@ jobs:
- name: Set up .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 9.0.x
dotnet-version: 10.0.x
- name: Download Dalamud Latest
run: |
wget https://goatcorp.github.io/dalamud-distrib/latest.zip -O ${{ env.DALAMUD_HOME }}.zip
wget https://goatcorp.github.io/dalamud-distrib/stg/latest.zip -O ${{ env.DALAMUD_HOME }}.zip
unzip ${{ env.DALAMUD_HOME }}.zip -d ${{ env.DALAMUD_HOME }}
- name: Restore Project

View File

@@ -2,10 +2,6 @@
Update honorific title based on discord activity informations.
## Installation
Installable using my custom repository (instructions here: https://github.com/anya-hichu/DalamudPluginRepo) or from compiled archives.
## Commands

View File

@@ -6,6 +6,12 @@ using Dalamud.Plugin.Services;
using SpotifyHonorific.Windows;
using SpotifyHonorific.Activities;
using SpotifyHonorific.Updaters;
using System;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
using System.Xml.Linq;
using System.Numerics;
namespace SpotifyHonorific;
@@ -70,6 +76,87 @@ public sealed class Plugin : IDalamudPlugin
Config.Save();
Updater.Stop();
}
else if (subcommand == "set")
{
var splitArgs = args.Trim().Split(' ', 2, StringSplitOptions.TrimEntries | StringSplitOptions.RemoveEmptyEntries);
if (splitArgs.Length != 2)
{
return;
}
var setArgs = splitArgs[1].Split('|', StringSplitOptions.TrimEntries | StringSplitOptions.RemoveEmptyEntries);
bool? prefix = null;
Vector3? color = null;
Vector3? glow = null;
foreach (var a in setArgs)
{
var arg = a.ToLower();
var colorArg = arg.Skip(arg.StartsWith('#') ? 1 : 0).ToArray();
if (colorArg.Length == 6 && colorArg.All(chr => chr is >= '0' and <= '9' or >= 'a' and <= 'f'))
{
if (color != null && glow != null)
{
ChatGui.PrintError($"Duplicate Option in Set: '{a}'", "SpotifyHonorific");
return;
}
var rHex = string.Join(null, colorArg.Skip(0).Take(2));
var gHex = string.Join(null, colorArg.Skip(2).Take(2));
var bHex = string.Join(null, colorArg.Skip(4).Take(2));
if (byte.TryParse(rHex, NumberStyles.HexNumber, NumberFormatInfo.InvariantInfo, out var r) &&
byte.TryParse(gHex, NumberStyles.HexNumber, NumberFormatInfo.InvariantInfo, out var g) &&
byte.TryParse(bHex, NumberStyles.HexNumber, NumberFormatInfo.InvariantInfo, out var b))
{
var c = new Vector3(r / 255f, g / 255f, b / 255f);
if (color == null)
{
color = c;
continue;
}
glow = c;
continue;
}
}
if (arg is "p" or "prefix" or "pre")
{
if (prefix != null)
{
ChatGui.PrintError($"Duplicate Option in Set: '{a}'", "SpotifyHonorific");
return;
}
prefix = true;
continue;
}
if (arg is "s" or "suffix")
{
if (prefix != null)
{
ChatGui.PrintError($"Duplicate Option in Set: '{a}'", "SpotifyHonorific");
return;
}
prefix = false;
continue;
}
ChatGui.PrintError($"Invalid Option in Set: '{a}'", "SpotifyHonorific");
return;
}
Config.ActivityConfigs.First().Color = color;
Config.ActivityConfigs.First().Glow = glow;
Config.ActivityConfigs.First().IsPrefix = prefix ?? false;
ChatGui.Print("Updated Title", "SpotifyHonorific");
}
else
{
ChatGui.Print(CommandHelpMessage);

View File

@@ -1,12 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Dalamud.NET.Sdk/12.0.2">
<Project Sdk="Dalamud.NET.Sdk/14.0.1">
<PropertyGroup>
<Description>Update honorific title based on spotify informations</Description>
<IsPackable>false</IsPackable>
<TargetFramework>net9.0-windows7.0</TargetFramework>
<TargetFramework>net10.0-windows7.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Scriban" Version="6.0.0" />
<PackageReference Include="Scriban" Version="6.5.2" />
</ItemGroup>
<ItemGroup>
<Reference Remove="ImGui.NET" />
<Reference Include="Dalamud.Bindings.ImGui" Private="false" />
<Reference Include="Dalamud.Bindings.ImPlot" Private="false" />
<Reference Include="Dalamud.Bindings.ImGuizmo" Private="false" />
</ItemGroup>
<ItemGroup>
<PackageReference Update="DalamudPackager" Version="14.0.1" />
<PackageReference Update="DotNet.ReproducibleBuilds" Version="1.2.39" />
</ItemGroup>
</Project>

View File

@@ -8,6 +8,8 @@ using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Timers;
@@ -147,25 +149,63 @@ public class Updater : IDisposable
try
{
var spotifyProcesses = Process.GetProcessesByName("Spotify");
var trackTitles = new List<string>();
foreach (var process in spotifyProcesses)
{
if (!string.IsNullOrEmpty(process.MainWindowTitle) &&
process.MainWindowTitle != "Spotify" &&
process.MainWindowTitle != "Spotify Premium" &&
process.MainWindowTitle != "Spotify Free")
EnumWindows((hWnd, lParam) =>
{
return process.MainWindowTitle;
}
uint processId;
GetWindowThreadProcessId(hWnd, out processId);
if (processId == process.Id)
{
var title = GetWindowTitle(hWnd);
if (!string.IsNullOrEmpty(title) &&
title != "Spotify" &&
title != "Spotify Premium" &&
title != "Spotify Free" &&
title.Contains(" - "))
{
trackTitles.Add(title);
}
}
return true;
}, IntPtr.Zero);
}
return trackTitles.OrderByDescending(t => t.Length).FirstOrDefault();
}
catch (Exception ex)
{
PluginLog.Debug($"Error getting Spotify track: {ex.Message}");
}
return null;
}
private string GetWindowTitle(IntPtr hWnd)
{
const int nChars = 256;
var buff = new StringBuilder(nChars);
if (GetWindowTextW(hWnd, buff, nChars) > 0)
{
return buff.ToString();
}
return string.Empty;
}
[DllImport("user32.dll")]
private static extern bool EnumWindows(EnumWindowsProc enumProc, IntPtr lParam);
[DllImport("user32.dll")]
private static extern uint GetWindowThreadProcessId(IntPtr hWnd, out uint lpdwProcessId);
[DllImport("user32.dll", CharSet = CharSet.Unicode)]
private static extern int GetWindowTextW(IntPtr hWnd, StringBuilder text, int count);
private delegate bool EnumWindowsProc(IntPtr hWnd, IntPtr lParam);
private bool MediaActivitiesEqual(MediaActivity? a, MediaActivity? b)
{
if (a == null && b == null) return true;

View File

@@ -1,7 +1,7 @@
using Dalamud.Interface.Utility;
using ImGuiNET;
using Dalamud.Bindings.ImGui;
using System.Numerics;
namespace SpotifyHonorific.Utils;

View File

@@ -2,7 +2,7 @@ using Dalamud.Interface.Windowing;
using Dalamud.Utility;
using SpotifyHonorific.Updaters;
using SpotifyHonorific.Utils;
using ImGuiNET;
using Dalamud.Bindings.ImGui;
using System.Numerics;
namespace SpotifyHonorific.Windows;

View File

@@ -1,24 +1,24 @@
{
"version": 1,
"dependencies": {
"net9.0-windows7.0": {
"net10.0-windows7.0": {
"DalamudPackager": {
"type": "Direct",
"requested": "[12.0.0, )",
"resolved": "12.0.0",
"contentHash": "J5TJLV3f16T/E2H2P17ClWjtfEBPpq3yxvqW46eN36JCm6wR+EaoaYkqG9Rm5sHqs3/nK/vKjWWyvEs/jhKoXw=="
"requested": "[14.0.1, )",
"resolved": "14.0.1",
"contentHash": "y0WWyUE6dhpGdolK3iKgwys05/nZaVf4ZPtIjpLhJBZvHxkkiE23zYRo7K7uqAgoK/QvK5cqF6l3VG5AbgC6KA=="
},
"DotNet.ReproducibleBuilds": {
"type": "Direct",
"requested": "[1.2.25, )",
"resolved": "1.2.25",
"contentHash": "xCXiw7BCxHJ8pF6wPepRUddlh2dlQlbr81gXA72hdk4FLHkKXas7EH/n+fk5UCA/YfMqG1Z6XaPiUjDbUNBUzg=="
"requested": "[1.2.39, )",
"resolved": "1.2.39",
"contentHash": "fcFN01tDTIQqDuTwr1jUQK/geofiwjG5DycJQOnC72i1SsLAk1ELe+apBOuZ11UMQG8YKFZG1FgvjZPbqHyatg=="
},
"Scriban": {
"type": "Direct",
"requested": "[6.0.0, )",
"resolved": "6.0.0",
"contentHash": "MZOtxtcehrCGiVwHpdcZQSe04Zy4IJfltVZdmlr1nFvSvEXnu50SWa7fonC0bqfMyTnNhQcY9BmEt882P129qw=="
"requested": "[6.5.2, )",
"resolved": "6.5.2",
"contentHash": "JXli/Sh1WVZs/pqnPPRJTlwEsZHPJtndzxiaPnrteXDpAqVqHxh4ifhx4puTaYKVMPJUMOp9bnCpEVBpYlt/eQ=="
}
}
}