chore: initial commit

This commit is contained in:
Anna 2021-01-13 23:06:35 -05:00
commit af7e4275e8
15 changed files with 1585 additions and 0 deletions

364
.gitignore vendored Executable file
View File

@ -0,0 +1,364 @@
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
##
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
# User-specific files
*.rsuser
*.suo
*.user
*.userosscache
*.sln.docstates
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
# Mono auto generated files
mono_crash.*
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
[Ww][Ii][Nn]32/
[Aa][Rr][Mm]/
[Aa][Rr][Mm]64/
bld/
[Bb]in/
[Oo]bj/
[Ll]og/
[Ll]ogs/
# Visual Studio 2015/2017 cache/options directory
.vs/
# Rider
.idea/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/
# Visual Studio 2017 auto generated files
Generated\ Files/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
# NUnit
*.VisualState.xml
TestResult.xml
nunit-*.xml
# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c
# Benchmark Results
BenchmarkDotNet.Artifacts/
# .NET Core
project.lock.json
project.fragment.lock.json
artifacts/
# ASP.NET Scaffolding
ScaffoldingReadMe.txt
# StyleCop
StyleCopReport.xml
# Files built by Visual Studio
*_i.c
*_p.c
*_h.h
*.ilk
*.meta
*.obj
*.iobj
*.pch
*.pdb
*.ipdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*_wpftmp.csproj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc
# Chutzpah Test files
_Chutzpah*
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opendb
*.opensdf
*.sdf
*.cachefile
*.VC.db
*.VC.VC.opendb
# Visual Studio profiler
*.psess
*.vsp
*.vspx
*.sap
# Visual Studio Trace Files
*.e2e
# TFS 2012 Local Workspace
$tf/
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# AxoCover is a Code Coverage Tool
.axoCover/*
!.axoCover/settings.json
# Coverlet is a free, cross platform Code Coverage Tool
coverage*.json
coverage*.xml
coverage*.info
# Visual Studio code coverage results
*.coverage
*.coveragexml
# NCrunch
_NCrunch_*
.*crunch*.local.xml
nCrunchTemp_*
# MightyMoose
*.mm.*
AutoTest.Net/
# Web workbench (sass)
.sass-cache/
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# Note: Comment the next line if you want to checkin your web deploy settings,
# but database connection strings (with potential passwords) will be unencrypted
*.pubxml
*.publishproj
# Microsoft Azure Web App publish settings. Comment the next line if you want to
# checkin your Azure Web App publish settings, but sensitive information contained
# in these scripts will be unencrypted
PublishScripts/
# NuGet Packages
*.nupkg
# NuGet Symbol Packages
*.snupkg
# The packages folder can be ignored because of Package Restore
**/[Pp]ackages/*
# except build/, which is used as an MSBuild target.
!**/[Pp]ackages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/[Pp]ackages/repositories.config
# NuGet v3's project.json files produces more ignorable files
*.nuget.props
*.nuget.targets
# Microsoft Azure Build Output
csx/
*.build.csdef
# Microsoft Azure Emulator
ecf/
rcf/
# Windows Store app package directories and files
AppPackages/
BundleArtifacts/
Package.StoreAssociation.xml
_pkginfo.txt
*.appx
*.appxbundle
*.appxupload
# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!?*.[Cc]ache/
# Others
ClientBin/
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.jfm
*.pfx
*.publishsettings
orleans.codegen.cs
# Including strong name files can present a security risk
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
#*.snk
# Since there are multiple workflows, uncomment next line to ignore bower_components
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
#bower_components/
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
ServiceFabricBackup/
*.rptproj.bak
# SQL Server files
*.mdf
*.ldf
*.ndf
# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings
*.rptproj.rsuser
*- [Bb]ackup.rdl
*- [Bb]ackup ([0-9]).rdl
*- [Bb]ackup ([0-9][0-9]).rdl
# Microsoft Fakes
FakesAssemblies/
# GhostDoc plugin setting file
*.GhostDoc.xml
# Node.js Tools for Visual Studio
.ntvs_analysis.dat
node_modules/
# Visual Studio 6 build log
*.plg
# Visual Studio 6 workspace options file
*.opt
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
*.vbw
# Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts
**/*.DesktopClient/ModelManifest.xml
**/*.Server/GeneratedArtifacts
**/*.Server/ModelManifest.xml
_Pvt_Extensions
# Paket dependency manager
.paket/paket.exe
paket-files/
# FAKE - F# Make
.fake/
# CodeRush personal settings
.cr/personal
# Python Tools for Visual Studio (PTVS)
__pycache__/
*.pyc
# Cake - Uncomment if you are using it
# tools/**
# !tools/packages.config
# Tabs Studio
*.tss
# Telerik's JustMock configuration file
*.jmconfig
# BizTalk build output
*.btp.cs
*.btm.cs
*.odx.cs
*.xsd.cs
# OpenCover UI analysis results
OpenCover/
# Azure Stream Analytics local run output
ASALocalRun/
# MSBuild Binary and Structured Log
*.binlog
# NVidia Nsight GPU debugger configuration file
*.nvuser
# MFractors (Xamarin productivity tool) working folder
.mfractor/
# Local History for Visual Studio
.localhistory/
# BeatPulse healthcheck temp database
healthchecksdb
# Backup folder for Package Reference Convert tool in Visual Studio 2017
MigrationBackup/
# Ionide (cross platform F# VS Code tools) working folder
.ionide/
# Fody - auto-generated XML schema
FodyWeavers.xsd

16
BetterPartyFinder.sln Executable file
View File

@ -0,0 +1,16 @@

Microsoft Visual Studio Solution File, Format Version 12.00
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BetterPartyFinder", "BetterPartyFinder\BetterPartyFinder.csproj", "{3692974D-42C1-4590-AB61-3D94D26A0634}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{3692974D-42C1-4590-AB61-3D94D26A0634}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3692974D-42C1-4590-AB61-3D94D26A0634}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3692974D-42C1-4590-AB61-3D94D26A0634}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3692974D-42C1-4590-AB61-3D94D26A0634}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal

View File

@ -0,0 +1,41 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net48</TargetFramework>
<Version>1.0.0</Version>
<LangVersion>latest</LangVersion>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<Reference Include="Dalamud, Version=5.2.2.0, Culture=neutral, PublicKeyToken=null">
<HintPath>$(AppData)\XIVLauncher\addon\Hooks\Dalamud.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="ImGui.NET, Version=1.72.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>$(AppData)\XIVLauncher\addon\Hooks\ImGui.NET.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="ImGuiScene, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>$(AppData)\XIVLauncher\addon\Hooks\ImGuiScene.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Lumina, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>$(AppData)\XIVLauncher\addon\Hooks\Lumina.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Lumina.Excel, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>$(AppData)\XIVLauncher\addon\Hooks\Lumina.Excel.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="System.Memory, Version=4.0.1.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51">
<HintPath>$(AppData)\XIVLauncher\addon\Hooks\System.Memory.dll</HintPath>
<Private>False</Private>
</Reference>
</ItemGroup>
<ItemGroup>
<PackageReference Include="DalamudPackager" Version="1.2.0" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,14 @@
author: ascclemens
name: Better Party Finder
description: |-
Filter the party finder better.
All vanilla filtering is available, plus:
- Create filter presets to easily switch between
- Whitelist/blacklist specific duties
- Add character names to hide PFs from
- Remove PFs above maximum item level
- Filter on item level range
- Filter on multiple jobs (ex. MCH + GNB available)
- Only show PFs that your party can join

View File

@ -0,0 +1,39 @@
using System;
using System.Collections.Generic;
using Dalamud.Configuration;
namespace BetterPartyFinder {
public class Configuration : IPluginConfiguration {
private Plugin? Plugin { get; set; }
public int Version { get; set; } = 1;
public Dictionary<Guid, ConfigurationFilter> Presets { get; } = new();
public Guid? SelectedPreset { get; set; } = null;
internal void Initialise(Plugin plugin) {
this.Plugin = plugin;
}
internal void Save() {
this.Plugin?.Interface.SavePluginConfig(this);
}
}
public class ConfigurationFilter {
public string Name { get; set; } = "<unnamed preset>";
public ListMode ListMode { get; set; } = ListMode.Blacklist;
public List<uint> Duties { get; set; } = new();
public List<JobFlags> Jobs { get; set; } = new();
// default to true because that's the PF's default
// use nosol if trying to avoid spam
public bool AllowHugeItemLevel { get; set; } = true;
public uint? MinItemLevel { get; set; }
public uint? MaxItemLevel { get; set; }
}
public enum ListMode {
Whitelist,
Blacklist,
}
}

View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<Project>
<Target Name="PackagePlugin" AfterTargets="Build" Condition="'$(Configuration)' == 'Release'">
<DalamudPackager
ProjectDir="$(ProjectDir)"
OutputPath="$(OutputPath)"
AssemblyName="$(AssemblyName)"
VersionComponents="3"
MakeZip="true"/>
</Target>
</Project>

56
BetterPartyFinder/Filter.cs Executable file
View File

@ -0,0 +1,56 @@
using System;
namespace BetterPartyFinder {
public class Filter : IDisposable {
private Plugin Plugin { get; }
internal Filter(Plugin plugin) {
this.Plugin = plugin;
this.Plugin.Functions.ReceivePartyFinderListing += this.ReceiveListing;
}
private void ReceiveListing(PartyFinderListing listing, PartyFinderListingEventArgs args) {
args.Visible = this.ListingVisible(listing);
}
private bool ListingVisible(PartyFinderListing listing) {
// get the current preset or mark all pfs as visible
var selectedId = this.Plugin.Config.SelectedPreset;
if (selectedId == null || !this.Plugin.Config.Presets.TryGetValue(selectedId.Value, out var filter)) {
return true;
}
// check max item level
if (!filter.AllowHugeItemLevel && Util.MaxItemLevel > 0 && listing.MinimumItemLevel > Util.MaxItemLevel) {
return false;
}
// filter based on duty whitelist/blacklist
if (filter.Duties.Count > 0 && listing.DutyType == DutyType.Normal) {
var inList = filter.Duties.Contains(listing.RawDuty);
// ReSharper disable once SwitchStatementHandlesSomeKnownEnumValuesWithDefault
switch (filter.ListMode) {
case ListMode.Blacklist when inList:
case ListMode.Whitelist when !inList:
return false;
}
}
// filter based on item level range
if (filter.MinItemLevel != null && listing.MinimumItemLevel < filter.MinItemLevel) {
return false;
}
if (filter.MaxItemLevel != null && listing.MinimumItemLevel > filter.MaxItemLevel) {
return false;
}
return true;
}
public void Dispose() {
this.Plugin.Functions.ReceivePartyFinderListing -= this.ReceiveListing;
}
}
}

View File

@ -0,0 +1,97 @@
using System;
using System.Linq;
using System.Runtime.InteropServices;
using Dalamud.Hooking;
using Dalamud.Plugin;
namespace BetterPartyFinder {
public class GameFunctions : IDisposable {
private Plugin Plugin { get; }
internal delegate void PartyFinderListingEventDelegate(PartyFinderListing listing, PartyFinderListingEventArgs args);
internal event PartyFinderListingEventDelegate? ReceivePartyFinderListing;
private delegate void HandlePfPacketDelegate(IntPtr param1, IntPtr data);
private readonly Hook<HandlePfPacketDelegate>? _handlePacketHook;
internal GameFunctions(Plugin plugin) {
this.Plugin = plugin;
var listingPtr = this.Plugin.Interface.TargetModuleScanner.ScanText("40 53 41 57 48 83 EC 28 48 8B D9");
this._handlePacketHook = new Hook<HandlePfPacketDelegate>(listingPtr, new HandlePfPacketDelegate(this.PacketDetour));
this._handlePacketHook.Enable();
}
private void PacketDetour(IntPtr param1, IntPtr data) {
if (data == IntPtr.Zero) {
goto Return;
}
try {
this.OnPacket(data);
} catch (Exception ex) {
PluginLog.Error(ex, "Unhandled exception in PF packet detour");
}
Return:
this._handlePacketHook!.Original(param1, data);
}
private void OnPacket(IntPtr data) {
var dataPtr = data + 0x10;
// parse the packet into a struct
var packet = Marshal.PtrToStructure<PfPacket>(dataPtr);
var needToRewrite = false;
for (var i = 0; i < packet.listings.Length; i++) {
if (packet.listings[i].IsNull()) {
continue;
}
// invoke event for each non-null listing
var listing = new PartyFinderListing(packet.listings[i], this.Plugin.Interface.Data);
var args = new PartyFinderListingEventArgs();
this.ReceivePartyFinderListing?.Invoke(listing, args);
if (args.Visible) {
continue;
}
// zero the listing if it shouldn't be visible
packet.listings[i] = new PfListing();
needToRewrite = true;
}
if (!needToRewrite) {
return;
}
// get some memory for writing to
var newPacket = new byte[PacketInfo.PacketSize];
var pinnedArray = GCHandle.Alloc(newPacket, GCHandleType.Pinned);
var pointer = pinnedArray.AddrOfPinnedObject();
// write our struct into the memory (doing this directly crashes the game)
Marshal.StructureToPtr(packet, pointer, false);
// copy our new memory over the game's
Marshal.Copy(newPacket, 0, dataPtr, PacketInfo.PacketSize);
// free memory
pinnedArray.Free();
}
public void Dispose() {
this._handlePacketHook?.Dispose();
}
}
internal class PartyFinderListingEventArgs {
public bool Visible { get; set; } = true;
}
}

178
BetterPartyFinder/PartyFinder.cs Executable file
View File

@ -0,0 +1,178 @@
using Dalamud.Data;
using Lumina.Excel.GeneratedSheets;
using System;
using System.Collections.Generic;
using System.Linq;
namespace BetterPartyFinder {
public class PartyFinderListing {
public uint Id { get; }
public string Name { get; }
public string Description { get; }
public Lazy<World> World { get; }
public Lazy<World> HomeWorld { get; }
public Lazy<World> CurrentWorld { get; }
public Category Category { get; }
public ushort RawDuty { get; }
public Lazy<ContentFinderCondition> Duty { get; }
public DutyType DutyType { get; }
public bool BeginnersWelcome { get; }
public ushort SecondsRemaining { get; }
public ushort MinimumItemLevel { get; }
public IReadOnlyCollection<PartyFinderSlot> Slots => this._slots;
private readonly byte _objective;
private readonly byte _conditions;
private readonly byte _dutyFinderSettings;
private readonly byte _lootRules;
private readonly byte _searchArea;
private readonly PartyFinderSlot[] _slots;
public bool this[ObjectiveFlags flag] => (this._objective & (uint) flag) > 0;
public bool this[ConditionFlags flag] => (this._conditions & (uint) flag) > 0;
public bool this[DutyFinderSettingsFlags flag] => (this._dutyFinderSettings & (uint) flag) > 0;
public bool this[LootRuleFlags flag] => (this._lootRules & (uint) flag) > 0;
public bool this[SearchAreaFlags flag] => (this._searchArea & (uint) flag) > 0;
internal PartyFinderListing(PfListing listing, DataManager dataManager) {
this.Id = listing.id;
this.Name = listing.Name();
this.Description = listing.Description();
this.World = new Lazy<World>(() => dataManager.GetExcelSheet<World>().GetRow(listing.world));
this.HomeWorld = new Lazy<World>(() => dataManager.GetExcelSheet<World>().GetRow(listing.homeWorld));
this.CurrentWorld = new Lazy<World>(() => dataManager.GetExcelSheet<World>().GetRow(listing.currentWorld));
this.Category = (Category) listing.category;
this.RawDuty = listing.duty;
this.Duty = new Lazy<ContentFinderCondition>(() => dataManager.GetExcelSheet<ContentFinderCondition>().GetRow(listing.duty));
this.DutyType = (DutyType) listing.dutyType;
this.BeginnersWelcome = listing.beginnersWelcome == 1;
this.SecondsRemaining = listing.secondsRemaining;
this.MinimumItemLevel = listing.minimumItemLevel;
this._objective = listing.objective;
this._conditions = listing.conditions;
this._dutyFinderSettings = listing.dutyFinderSettings;
this._lootRules = listing.lootRules;
this._searchArea = listing.searchArea;
this._slots = listing.slots.Select(accepting => new PartyFinderSlot(accepting)).ToArray();
}
}
public class PartyFinderSlot {
private readonly uint _accepting;
private JobFlags[]? _listAccepting;
public IReadOnlyCollection<JobFlags> Accepting {
get {
if (this._listAccepting != null) {
return this._listAccepting;
}
this._listAccepting = Enum.GetValues(typeof(JobFlags))
.Cast<JobFlags>()
.Where(flag => this[flag])
.ToArray();
return this._listAccepting;
}
}
public bool this[JobFlags flag] => (this._accepting & (uint) flag) > 0;
internal PartyFinderSlot(uint accepting) {
this._accepting = accepting;
}
}
[Flags]
public enum SearchAreaFlags {
DataCentre = 1 << 0,
Private = 1 << 1,
Unknown2 = 1 << 2, // set for copied factory pf
World = 1 << 3,
OnePlayerPerJob = 1 << 5,
}
[Flags]
public enum JobFlags {
Gladiator = 1 << 1,
Pugilist = 1 << 2,
Marauder = 1 << 3,
Lancer = 1 << 4,
Archer = 1 << 5,
Conjurer = 1 << 6,
Thamaturge = 1 << 7,
Paladin = 1 << 8,
Monk = 1 << 9,
Warrior = 1 << 10,
Dragoon = 1 << 11,
Bard = 1 << 12,
WhiteMage = 1 << 13,
BlackMage = 1 << 14,
Arcanist = 1 << 15,
Summoner = 1 << 16,
Scholar = 1 << 17,
Rogue = 1 << 18,
Ninja = 1 << 19,
Machinist = 1 << 20,
DarkKnight = 1 << 21,
Astrologian = 1 << 22,
Samurai = 1 << 23,
RedMage = 1 << 24,
BlueMage = 1 << 25,
Gunbreaker = 1 << 26,
Dancer = 1 << 27,
}
[Flags]
public enum ObjectiveFlags {
None = 0,
DutyCompletion = 1,
Practice = 2,
Loot = 4,
}
[Flags]
public enum ConditionFlags {
None = 1,
DutyComplete = 2,
DutyIncomplete = 4,
}
[Flags]
public enum DutyFinderSettingsFlags {
None = 0,
UndersizedParty = 1,
MinimumItemLevel = 2,
}
[Flags]
public enum LootRuleFlags {
None = 0,
GreedOnly = 1,
Lootmaster = 2,
}
public enum Category {
Duty = 0,
QuestBattles = 1 << 0,
Fates = 1 << 1,
TreasureHunt = 1 << 2,
TheHunt = 1 << 3,
GatheringForays = 1 << 4,
DeepDungeons = 1 << 5,
AdventuringForays = 1 << 6,
}
public enum DutyType {
Other = 0,
Roulette = 1 << 0,
Normal = 1 << 1,
}
}

116
BetterPartyFinder/PfPacket.cs Executable file
View File

@ -0,0 +1,116 @@
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
namespace BetterPartyFinder {
public static class PacketInfo {
public static readonly int PacketSize = Marshal.SizeOf<PfPacket>();
}
[StructLayout(LayoutKind.Sequential)]
public struct PfPacket {
private readonly int unk0;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)]
private readonly byte[] padding1;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
public PfListing[] listings;
}
[StructLayout(LayoutKind.Sequential)]
public readonly struct PfListing {
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
private readonly byte[] header1;
internal readonly uint id;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
private readonly byte[] header2;
private readonly uint unknownInt1;
private readonly ushort unknownShort1;
private readonly ushort unknownShort2;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 5)]
private readonly byte[] header3;
internal readonly byte category;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)]
private readonly byte[] header4;
internal readonly ushort duty;
internal readonly byte dutyType;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 11)]
private readonly byte[] header5;
internal readonly ushort world;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)]
private readonly byte[] header6;
internal readonly byte objective;
internal readonly byte beginnersWelcome;
internal readonly byte conditions;
internal readonly byte dutyFinderSettings;
internal readonly byte lootRules;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)]
private readonly byte[] header7; // all zero in every pf I've examined
private readonly uint lastPatchHotfixTimestamp; // last time the servers were restarted?
internal readonly ushort secondsRemaining;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 6)]
private readonly byte[] header8; // 00 00 01 00 00 00 in every pf I've examined
internal readonly ushort minimumItemLevel;
internal readonly ushort homeWorld;
internal readonly ushort currentWorld;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
private readonly byte[] header9; // 02 XX 01 00 in every pf I've examined
internal readonly byte searchArea;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 5)]
private readonly byte[] header10; // 00 01 00 00 00 for every pf except alliance raids where it's 01 03 00 00 00 (second byte # parties?)
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)]
internal readonly uint[] slots;
private readonly uint job; // job started as?
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
private readonly byte[] header11; // all zero in every pf I've examined
// Note that ByValTStr will not work here because the strings are UTF-8 and there's only a CharSet for UTF-16 in C#.
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)]
private readonly byte[] name;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 192)]
private readonly byte[] description;
// 128 (0x80) before name and desc
// 160 (0xA0) with name (32 bytes/0x20)
// 352 (0x160) with both (192 bytes/0xC0)
private static string HandleString(IEnumerable<byte> bytes) {
var nonNull = bytes.TakeWhile(b => b != 0).ToArray();
return Encoding.UTF8.GetString(nonNull);
}
internal string Name() {
return HandleString(this.name);
}
internal string Description() {
return HandleString(this.description);
}
internal bool IsNull() {
// a valid party finder must have at least one slot set
return this.slots.All(slot => slot == 0);
}
}
}

34
BetterPartyFinder/Plugin.cs Executable file
View File

@ -0,0 +1,34 @@
using System.Threading.Tasks;
using Dalamud.Plugin;
namespace BetterPartyFinder {
public class Plugin : IDalamudPlugin {
public string Name => "Better Party Finder";
internal DalamudPluginInterface Interface { get; private set; } = null!;
internal Configuration Config { get; private set; } = null!;
internal GameFunctions Functions { get; private set; } = null!;
internal Filter Filter { get; set; } = null!;
private PluginUi Ui { get; set; } = null!;
public void Initialize(DalamudPluginInterface pluginInterface) {
this.Interface = pluginInterface;
this.Config = (Configuration?) this.Interface.GetPluginConfig() ?? new Configuration();
this.Config.Initialise(this);
this.Functions = new GameFunctions(this);
this.Filter = new Filter(this);
this.Ui = new PluginUi(this);
// start task to determine maximum item level (based on max chestpiece)
Task.Run(() => Util.CalculateMaxItemLevel(this.Interface.Data));
}
public void Dispose() {
this.Ui.Dispose();
this.Filter.Dispose();
this.Functions.Dispose();
}
}
}

296
BetterPartyFinder/PluginUi.cs Executable file
View File

@ -0,0 +1,296 @@
using System;
using System.Drawing;
using System.Linq;
using System.Numerics;
using Dalamud.Interface;
using ImGuiNET;
using Lumina.Excel.GeneratedSheets;
namespace BetterPartyFinder {
public class PluginUi : IDisposable {
private static readonly uint[] AllowedContentTypes = {
2,
3,
4,
5,
6,
16,
21,
26,
28,
};
private Plugin Plugin { get; }
private string DutySearchQuery { get; set; } = string.Empty;
private string PresetName { get; set; } = string.Empty;
internal PluginUi(Plugin plugin) {
this.Plugin = plugin;
this.Plugin.Interface.UiBuilder.OnBuildUi += this.Draw;
}
public void Dispose() {
this.Plugin.Interface.UiBuilder.OnBuildUi -= this.Draw;
}
private static bool IconButton(FontAwesomeIcon icon, string? id = null) {
ImGui.PushFont(UiBuilder.IconFont);
var text = icon.ToIconString();
if (id != null) {
text += $"##{id}";
}
var result = ImGui.Button(text);
ImGui.PopFont();
return result;
}
private void Draw() {
if (!ImGui.Begin($"{this.Plugin.Name} settings")) {
return;
}
var selected = this.Plugin.Config.SelectedPreset;
string selectedName;
if (selected == null) {
selectedName = "<none>";
} else {
if (this.Plugin.Config.Presets.TryGetValue(selected.Value, out var preset)) {
selectedName = preset.Name;
} else {
this.Plugin.Config.SelectedPreset = null;
selectedName = "<invalid preset>";
}
}
ImGui.TextUnformatted("Preset");
if (ImGui.BeginCombo("###preset", selectedName)) {
if (ImGui.Selectable("<none>")) {
this.Plugin.Config.SelectedPreset = null;
this.Plugin.Config.Save();
}
foreach (var preset in this.Plugin.Config.Presets) {
if (!ImGui.Selectable(preset.Value.Name)) {
continue;
}
this.Plugin.Config.SelectedPreset = preset.Key;
this.Plugin.Config.Save();
}
ImGui.EndCombo();
}
ImGui.SameLine();
if (IconButton(FontAwesomeIcon.Plus, "add-preset")) {
this.Plugin.Config.Presets.Add(Guid.NewGuid(), new ConfigurationFilter());
this.Plugin.Config.Save();
}
ImGui.SameLine();
if (IconButton(FontAwesomeIcon.Trash, "delete-preset") && selected != null) {
this.Plugin.Config.Presets.Remove(selected.Value);
this.Plugin.Config.Save();
}
ImGui.SameLine();
if (IconButton(FontAwesomeIcon.PencilAlt, "edit-preset") && selected != null) {
if (this.Plugin.Config.Presets.TryGetValue(selected.Value, out var editPreset)) {
this.PresetName = editPreset.Name;
ImGui.OpenPopup("###rename-preset");
}
}
if (ImGui.BeginPopupModal("Rename preset###rename-preset")) {
if (selected != null && this.Plugin.Config.Presets.TryGetValue(selected.Value, out var editPreset)) {
ImGui.TextUnformatted("Preset name");
ImGui.PushItemWidth(-1f);
var name = this.PresetName;
if (ImGui.InputText("###preset-name", ref name, 1_000)) {
this.PresetName = name;
}
ImGui.PopItemWidth();
if (ImGui.Button("Save") && this.PresetName.Trim().Length > 0) {
editPreset.Name = this.PresetName;
this.Plugin.Config.Save();
ImGui.CloseCurrentPopup();
}
ImGui.EndPopup();
}
}
ImGui.Separator();
if (selected != null && this.Plugin.Config.Presets.TryGetValue(selected.Value, out var filter)) {
this.DrawPresetConfiguration(filter);
}
ImGui.End();
}
private void DrawPresetConfiguration(ConfigurationFilter filter) {
if (!ImGui.BeginTabBar("bpf-tabs")) {
return;
}
this.DrawCategoriesTab(filter);
this.DrawDutiesTab(filter);
this.DrawItemLevelTab(filter);
this.DrawJobsTab(filter);
this.DrawRestrictionsTab(filter);
ImGui.EndTabBar();
}
private void DrawCategoriesTab(ConfigurationFilter filter) {
if (!ImGui.BeginTabItem("Categories")) {
return;
}
ImGui.TextUnformatted("Nothing here yet");
ImGui.EndTabItem();
}
private void DrawDutiesTab(ConfigurationFilter filter) {
if (!ImGui.BeginTabItem("Duties")) {
return;
}
var listModeStrings = new[] {
"Show ONLY these duties",
"Do NOT show these duties",
};
var listModeIdx = filter.ListMode == ListMode.Blacklist ? 1 : 0;
ImGui.TextUnformatted("List mode");
ImGui.PushItemWidth(-1);
if (ImGui.Combo("###list-mode", ref listModeIdx, listModeStrings, listModeStrings.Length)) {
filter.ListMode = listModeIdx == 0 ? ListMode.Whitelist : ListMode.Blacklist;
this.Plugin.Config.Save();
}
ImGui.PopItemWidth();
var query = this.DutySearchQuery;
ImGui.TextUnformatted("Search");
if (ImGui.InputText("###search", ref query, 1_000)) {
this.DutySearchQuery = query;
}
ImGui.SameLine();
if (ImGui.Button("Clear list")) {
filter.Duties.Clear();
this.Plugin.Config.Save();
}
if (ImGui.BeginChild("duty-selection", new Vector2(-1f, -1f))) {
var duties = this.Plugin.Interface.Data.GetExcelSheet<ContentFinderCondition>()
.Where(cf => cf.Unknown29)
.Where(cf => AllowedContentTypes.Contains(cf.ContentType.Row));
var searchQuery = this.DutySearchQuery.Trim();
if (searchQuery.Trim() != "") {
duties = duties.Where(duty => {
var sestring = this.Plugin.Interface.SeStringManager.Parse(duty.Name.RawData.ToArray());
return sestring.TextValue.ContainsIgnoreCase(searchQuery);
});
}
foreach (var cf in duties) {
var sestring = this.Plugin.Interface.SeStringManager.Parse(cf.Name.RawData.ToArray());
var selected = filter.Duties.Contains(cf.RowId);
var name = sestring.TextValue;
name = char.ToUpperInvariant(name[0]) + name.Substring(1);
if (!ImGui.Selectable(name, ref selected)) {
continue;
}
if (selected) {
filter.Duties.Add(cf.RowId);
} else {
filter.Duties.Remove(cf.RowId);
}
this.Plugin.Config.Save();
}
ImGui.EndChild();
}
ImGui.EndTabItem();
}
private void DrawItemLevelTab(ConfigurationFilter filter) {
if (!ImGui.BeginTabItem("Item level")) {
return;
}
var hugePfs = filter.AllowHugeItemLevel;
if (ImGui.Checkbox("Show PFs above maximum item level", ref hugePfs)) {
filter.AllowHugeItemLevel = hugePfs;
this.Plugin.Config.Save();
}
var minLevel = (int?) filter.MinItemLevel ?? 0;
ImGui.TextUnformatted("Minimum item level (0 to disable)");
ImGui.PushItemWidth(-1);
if (ImGui.InputInt("###min-ilvl", ref minLevel)) {
filter.MinItemLevel = minLevel == 0 ? null : (uint) minLevel;
this.Plugin.Config.Save();
}
ImGui.PopItemWidth();
var maxLevel = (int?) filter.MaxItemLevel ?? 0;
ImGui.TextUnformatted("Maximum item level (0 to disable)");
ImGui.PushItemWidth(-1);
if (ImGui.InputInt("###max-ilvl", ref maxLevel)) {
filter.MaxItemLevel = maxLevel == 0 ? null : (uint) maxLevel;
this.Plugin.Config.Save();
}
ImGui.PopItemWidth();
ImGui.EndTabItem();
}
private void DrawJobsTab(ConfigurationFilter filter) {
if (!ImGui.BeginTabItem("Jobs")) {
return;
}
ImGui.TextUnformatted("Nothing here yet");
ImGui.EndTabItem();
}
private void DrawRestrictionsTab(ConfigurationFilter filter) {
if (!ImGui.BeginTabItem("Restrictions")) {
return;
}
ImGui.TextUnformatted("Nothing here yet");
ImGui.EndTabItem();
}
}
}

29
BetterPartyFinder/Util.cs Executable file
View File

@ -0,0 +1,29 @@
using System.Globalization;
using System.Linq;
using Dalamud.Data;
using Lumina.Excel.GeneratedSheets;
namespace BetterPartyFinder {
public static class Util {
internal static uint MaxItemLevel { get; private set; }
internal static void CalculateMaxItemLevel(DataManager data) {
if (MaxItemLevel > 0) {
return;
}
var max = data.GetExcelSheet<Item>()
.Where(item => item.EquipSlotCategory.Value.Body != 0)
.Select(item => item.LevelItem.Value?.RowId)
.Where(level => level != null)
.Cast<uint>()
.Max();
MaxItemLevel = max;
}
internal static bool ContainsIgnoreCase(this string haystack, string needle) {
return CultureInfo.InvariantCulture.CompareInfo.IndexOf(haystack, needle, CompareOptions.IgnoreCase) >= 0;
}
}
}

287
LICENCE Executable file
View File

@ -0,0 +1,287 @@
EUROPEAN UNION PUBLIC LICENCE v. 1.2
EUPL © the European Union 2007, 2016
This European Union Public Licence (the EUPL) applies to the Work (as defined
below) which is provided under the terms of this Licence. Any use of the Work,
other than as authorised under this Licence is prohibited (to the extent such
use is covered by a right of the copyright holder of the Work).
The Work is provided under the terms of this Licence when the Licensor (as
defined below) has placed the following notice immediately following the
copyright notice for the Work:
Licensed under the EUPL
or has expressed by any other means his willingness to license under the EUPL.
1. Definitions
In this Licence, the following terms have the following meaning:
- The Licence: this Licence.
- The Original Work: the work or software distributed or communicated by the
Licensor under this Licence, available as Source Code and also as Executable
Code as the case may be.
- Derivative Works: the works or software that could be created by the
Licensee, based upon the Original Work or modifications thereof. This Licence
does not define the extent of modification or dependence on the Original Work
required in order to classify a work as a Derivative Work; this extent is
determined by copyright law applicable in the country mentioned in Article 15.
- The Work: the Original Work or its Derivative Works.
- The Source Code: the human-readable form of the Work which is the most
convenient for people to study and modify.
- The Executable Code: any code which has generally been compiled and which is
meant to be interpreted by a computer as a program.
- The Licensor: the natural or legal person that distributes or communicates
the Work under the Licence.
- Contributor(s): any natural or legal person who modifies the Work under the
Licence, or otherwise contributes to the creation of a Derivative Work.
- The Licensee or You: any natural or legal person who makes any usage of
the Work under the terms of the Licence.
- Distribution or Communication: any act of selling, giving, lending,
renting, distributing, communicating, transmitting, or otherwise making
available, online or offline, copies of the Work or providing access to its
essential functionalities at the disposal of any other natural or legal
person.
2. Scope of the rights granted by the Licence
The Licensor hereby grants You a worldwide, royalty-free, non-exclusive,
sublicensable licence to do the following, for the duration of copyright vested
in the Original Work:
- use the Work in any circumstance and for all usage,
- reproduce the Work,
- modify the Work, and make Derivative Works based upon the Work,
- communicate to the public, including the right to make available or display
the Work or copies thereof to the public and perform publicly, as the case may
be, the Work,
- distribute the Work or copies thereof,
- lend and rent the Work or copies thereof,
- sublicense rights in the Work or copies thereof.
Those rights can be exercised on any media, supports and formats, whether now
known or later invented, as far as the applicable law permits so.
In the countries where moral rights apply, the Licensor waives his right to
exercise his moral right to the extent allowed by law in order to make effective
the licence of the economic rights here above listed.
The Licensor grants to the Licensee royalty-free, non-exclusive usage rights to
any patents held by the Licensor, to the extent necessary to make use of the
rights granted on the Work under this Licence.
3. Communication of the Source Code
The Licensor may provide the Work either in its Source Code form, or as
Executable Code. If the Work is provided as Executable Code, the Licensor
provides in addition a machine-readable copy of the Source Code of the Work
along with each copy of the Work that the Licensor distributes or indicates, in
a notice following the copyright notice attached to the Work, a repository where
the Source Code is easily and freely accessible for as long as the Licensor
continues to distribute or communicate the Work.
4. Limitations on copyright
Nothing in this Licence is intended to deprive the Licensee of the benefits from
any exception or limitation to the exclusive rights of the rights owners in the
Work, of the exhaustion of those rights or of other applicable limitations
thereto.
5. Obligations of the Licensee
The grant of the rights mentioned above is subject to some restrictions and
obligations imposed on the Licensee. Those obligations are the following:
Attribution right: The Licensee shall keep intact all copyright, patent or
trademarks notices and all notices that refer to the Licence and to the
disclaimer of warranties. The Licensee must include a copy of such notices and a
copy of the Licence with every copy of the Work he/she distributes or
communicates. The Licensee must cause any Derivative Work to carry prominent
notices stating that the Work has been modified and the date of modification.
Copyleft clause: If the Licensee distributes or communicates copies of the
Original Works or Derivative Works, this Distribution or Communication will be
done under the terms of this Licence or of a later version of this Licence
unless the Original Work is expressly distributed only under this version of the
Licence — for example by communicating EUPL v. 1.2 only. The Licensee
(becoming Licensor) cannot offer or impose any additional terms or conditions on
the Work or Derivative Work that alter or restrict the terms of the Licence.
Compatibility clause: If the Licensee Distributes or Communicates Derivative
Works or copies thereof based upon both the Work and another work licensed under
a Compatible Licence, this Distribution or Communication can be done under the
terms of this Compatible Licence. For the sake of this clause, Compatible
Licence refers to the licences listed in the appendix attached to this Licence.
Should the Licensee's obligations under the Compatible Licence conflict with
his/her obligations under this Licence, the obligations of the Compatible
Licence shall prevail.
Provision of Source Code: When distributing or communicating copies of the Work,
the Licensee will provide a machine-readable copy of the Source Code or indicate
a repository where this Source will be easily and freely available for as long
as the Licensee continues to distribute or communicate the Work.
Legal Protection: This Licence does not grant permission to use the trade names,
trademarks, service marks, or names of the Licensor, except as required for
reasonable and customary use in describing the origin of the Work and
reproducing the content of the copyright notice.
6. Chain of Authorship
The original Licensor warrants that the copyright in the Original Work granted
hereunder is owned by him/her or licensed to him/her and that he/she has the
power and authority to grant the Licence.
Each Contributor warrants that the copyright in the modifications he/she brings
to the Work are owned by him/her or licensed to him/her and that he/she has the
power and authority to grant the Licence.
Each time You accept the Licence, the original Licensor and subsequent
Contributors grant You a licence to their contributions to the Work, under the
terms of this Licence.
7. Disclaimer of Warranty
The Work is a work in progress, which is continuously improved by numerous
Contributors. It is not a finished work and may therefore contain defects or
bugs inherent to this type of development.
For the above reason, the Work is provided under the Licence on an as is basis
and without warranties of any kind concerning the Work, including without
limitation merchantability, fitness for a particular purpose, absence of defects
or errors, accuracy, non-infringement of intellectual property rights other than
copyright as stated in Article 6 of this Licence.
This disclaimer of warranty is an essential part of the Licence and a condition
for the grant of any rights to the Work.
8. Disclaimer of Liability
Except in the cases of wilful misconduct or damages directly caused to natural
persons, the Licensor will in no event be liable for any direct or indirect,
material or moral, damages of any kind, arising out of the Licence or of the use
of the Work, including without limitation, damages for loss of goodwill, work
stoppage, computer failure or malfunction, loss of data or any commercial
damage, even if the Licensor has been advised of the possibility of such damage.
However, the Licensor will be liable under statutory product liability laws as
far such laws apply to the Work.
9. Additional agreements
While distributing the Work, You may choose to conclude an additional agreement,
defining obligations or services consistent with this Licence. However, if
accepting obligations, You may act only on your own behalf and on your sole
responsibility, not on behalf of the original Licensor or any other Contributor,
and only if You agree to indemnify, defend, and hold each Contributor harmless
for any liability incurred by, or claims asserted against such Contributor by
the fact You have accepted any warranty or additional liability.
10. Acceptance of the Licence
The provisions of this Licence can be accepted by clicking on an icon I agree
placed under the bottom of a window displaying the text of this Licence or by
affirming consent in any other similar way, in accordance with the rules of
applicable law. Clicking on that icon indicates your clear and irrevocable
acceptance of this Licence and all of its terms and conditions.
Similarly, you irrevocably accept this Licence and all of its terms and
conditions by exercising any rights granted to You by Article 2 of this Licence,
such as the use of the Work, the creation by You of a Derivative Work or the
Distribution or Communication by You of the Work or copies thereof.
11. Information to the public
In case of any Distribution or Communication of the Work by means of electronic
communication by You (for example, by offering to download the Work from a
remote location) the distribution channel or media (for example, a website) must
at least provide to the public the information requested by the applicable law
regarding the Licensor, the Licence and the way it may be accessible, concluded,
stored and reproduced by the Licensee.
12. Termination of the Licence
The Licence and the rights granted hereunder will terminate automatically upon
any breach by the Licensee of the terms of the Licence.
Such a termination will not terminate the licences of any person who has
received the Work from the Licensee under the Licence, provided such persons
remain in full compliance with the Licence.
13. Miscellaneous
Without prejudice of Article 9 above, the Licence represents the complete
agreement between the Parties as to the Work.
If any provision of the Licence is invalid or unenforceable under applicable
law, this will not affect the validity or enforceability of the Licence as a
whole. Such provision will be construed or reformed so as necessary to make it
valid and enforceable.
The European Commission may publish other linguistic versions or new versions of
this Licence or updated versions of the Appendix, so far this is required and
reasonable, without reducing the scope of the rights granted by the Licence. New
versions of the Licence will be published with a unique version number.
All linguistic versions of this Licence, approved by the European Commission,
have identical value. Parties can take advantage of the linguistic version of
their choice.
14. Jurisdiction
Without prejudice to specific agreement between parties,
- any litigation resulting from the interpretation of this License, arising
between the European Union institutions, bodies, offices or agencies, as a
Licensor, and any Licensee, will be subject to the jurisdiction of the Court
of Justice of the European Union, as laid down in article 272 of the Treaty on
the Functioning of the European Union,
- any litigation arising between other parties and resulting from the
interpretation of this License, will be subject to the exclusive jurisdiction
of the competent court where the Licensor resides or conducts its primary
business.
15. Applicable Law
Without prejudice to specific agreement between parties,
- this Licence shall be governed by the law of the European Union Member State
where the Licensor has his seat, resides or has his registered office,
- this licence shall be governed by Belgian law if the Licensor has no seat,
residence or registered office inside a European Union Member State.
Appendix
Compatible Licences according to Article 5 EUPL are:
- GNU General Public License (GPL) v. 2, v. 3
- GNU Affero General Public License (AGPL) v. 3
- Open Software License (OSL) v. 2.1, v. 3.0
- Eclipse Public License (EPL) v. 1.0
- CeCILL v. 2.0, v. 2.1
- Mozilla Public Licence (MPL) v. 2
- GNU Lesser General Public Licence (LGPL) v. 2.1, v. 3
- Creative Commons Attribution-ShareAlike v. 3.0 Unported (CC BY-SA 3.0) for
works other than software
- European Union Public Licence (EUPL) v. 1.1, v. 1.2
- Québec Free and Open-Source Licence — Reciprocity (LiLiQ-R) or Strong
Reciprocity (LiLiQ-R+).
The European Commission may update this Appendix to later versions of the above
licences without producing a new version of the EUPL, as long as they provide
the rights granted in Article 2 of this Licence and protect the covered Source
Code from exclusive appropriation.
All other changes or additions to this Appendix require the production of a new
EUPL version.

7
README.md Executable file
View File

@ -0,0 +1,7 @@
# Better Party Finder
A plugin enabling better filtering of the Party Finder.
---
It's not ready yet. Go away.