Compare commits
12 Commits
1.0.0.0
...
14980a9ec4
| Author | SHA1 | Date | |
|---|---|---|---|
| 14980a9ec4 | |||
| e9d0a2b606 | |||
| 885119dc47 | |||
| 6f825ec210 | |||
| 6578f83dd8 | |||
| cd23b9e381 | |||
| f299e04189 | |||
| 023418599e | |||
| b124838915 | |||
| 726ecc5688 | |||
| 561811cd1f | |||
| 0c0c72be9f |
4
.github/workflows/build.yml
vendored
4
.github/workflows/build.yml
vendored
@@ -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
|
||||
|
||||
8
.github/workflows/release.yml
vendored
8
.github/workflows/release.yml
vendored
@@ -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
|
||||
@@ -45,7 +45,7 @@ jobs:
|
||||
run: |
|
||||
curl \
|
||||
-X POST \
|
||||
-H "Authorization: token ${{ gitea.token }}" \
|
||||
-H "Authorization: token ${{ github.token }}" \
|
||||
-H "Content-Type: application/zip" \
|
||||
--data-binary @SpotifyHonorific/bin/Release/SpotifyHonorific/latest.zip \
|
||||
--data-binary @latest.zip \
|
||||
"${{ steps.create_release.outputs.upload_url }}?name=latest.zip"
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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.0">
|
||||
<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.0" />
|
||||
<PackageReference Update="DotNet.ReproducibleBuilds" Version="1.2.39" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
|
||||
|
||||
using Dalamud.Interface.Utility;
|
||||
using ImGuiNET;
|
||||
using Dalamud.Bindings.ImGui;
|
||||
using System.Numerics;
|
||||
|
||||
namespace SpotifyHonorific.Utils;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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.0, )",
|
||||
"resolved": "14.0.0",
|
||||
"contentHash": "9c1q/eAeAs82mkQWBOaCvbt3GIQxAIadz5b/7pCXDIy9nHPtnRc+tDXEvKR+M36Wvi7n+qBTevRupkLUQp6DFA=="
|
||||
},
|
||||
"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=="
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user