chore: restructure repo and include csharp
This commit is contained in:
parent
85bf1f36fc
commit
578c569390
|
@ -8,9 +8,9 @@ tasks:
|
|||
curl -L https://nixos.org/nix/install | sh -s
|
||||
echo 'source $HOME/.nix-profile/etc/profile.d/nix.sh' >> $HOME/.buildenv
|
||||
- build: |
|
||||
cd remote-party-finder
|
||||
cd remote-party-finder/server
|
||||
nix-shell --command 'cargo build --release'
|
||||
strip -s target/release/remote-party-finder
|
||||
nix-shell --command 'patchelf --remove-rpath --set-interpreter /usr/lib64/ld-linux-x86-64.so.2 target/release/remote-party-finder'
|
||||
artifacts:
|
||||
- remote-party-finder/target/release/remote-party-finder
|
||||
- remote-party-finder/server/target/release/remote-party-finder
|
||||
|
|
|
@ -0,0 +1,365 @@
|
|||
## 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
|
||||
|
||||
# Packaging
|
||||
pack/
|
||||
|
||||
# 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/
|
||||
# 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
|
|
@ -0,0 +1,22 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RemotePartyFinder", "RemotePartyFinder\RemotePartyFinder.csproj", "{3B6A57E7-EC71-4E5B-87F0-A110078F125D}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SourceGenerator", "SourceGenerator\SourceGenerator.csproj", "{B92F3AC2-2E24-4EB1-BE4D-A41E6216EA20}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{3B6A57E7-EC71-4E5B-87F0-A110078F125D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{3B6A57E7-EC71-4E5B-87F0-A110078F125D}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{3B6A57E7-EC71-4E5B-87F0-A110078F125D}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{3B6A57E7-EC71-4E5B-87F0-A110078F125D}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{B92F3AC2-2E24-4EB1-BE4D-A41E6216EA20}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{B92F3AC2-2E24-4EB1-BE4D-A41E6216EA20}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{B92F3AC2-2E24-4EB1-BE4D-A41E6216EA20}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{B92F3AC2-2E24-4EB1-BE4D-A41E6216EA20}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
EndGlobal
|
|
@ -0,0 +1,73 @@
|
|||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Threading.Tasks;
|
||||
using Dalamud.Game;
|
||||
using Dalamud.Game.Gui.PartyFinder.Types;
|
||||
using Dalamud.Logging;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace RemotePartyFinder {
|
||||
internal class Gatherer : IDisposable {
|
||||
#if DEBUG
|
||||
private const string UploadUrl = "http://192.168.174.240:7878/contribute/multiple";
|
||||
#elif RELEASE
|
||||
private const string UploadUrl = "https://rpf.annaclemens.io/contribute/multiple";
|
||||
#endif
|
||||
|
||||
private Plugin Plugin { get; }
|
||||
|
||||
private ConcurrentDictionary<int, List<PartyFinderListing>> Batches { get; } = new();
|
||||
private Stopwatch UploadTimer { get; } = new();
|
||||
private HttpClient Client { get; } = new();
|
||||
|
||||
internal Gatherer(Plugin plugin) {
|
||||
this.Plugin = plugin;
|
||||
|
||||
this.UploadTimer.Start();
|
||||
|
||||
this.Plugin.PartyFinderGui.ReceiveListing += this.OnListing;
|
||||
this.Plugin.Framework.Update += this.OnUpdate;
|
||||
}
|
||||
|
||||
public void Dispose() {
|
||||
this.Plugin.Framework.Update -= this.OnUpdate;
|
||||
this.Plugin.PartyFinderGui.ReceiveListing -= this.OnListing;
|
||||
}
|
||||
|
||||
private void OnListing(PartyFinderListing listing, PartyFinderListingEventArgs args) {
|
||||
if (!this.Batches.ContainsKey(args.BatchNumber)) {
|
||||
this.Batches[args.BatchNumber] = new List<PartyFinderListing>();
|
||||
}
|
||||
|
||||
this.Batches[args.BatchNumber].Add(listing);
|
||||
}
|
||||
|
||||
private void OnUpdate(Framework framework) {
|
||||
if (this.UploadTimer.Elapsed < TimeSpan.FromSeconds(10)) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.UploadTimer.Restart();
|
||||
|
||||
foreach (var (batch, listings) in this.Batches.ToList()) {
|
||||
this.Batches.Remove(batch, out _);
|
||||
Task.Run(async () => {
|
||||
var uploadable = listings
|
||||
.Select(listing => new UploadableListing(listing))
|
||||
.ToList();
|
||||
var json = JsonConvert.SerializeObject(uploadable);
|
||||
var resp = await this.Client.PostAsync(UploadUrl, new StringContent(json) {
|
||||
Headers = { ContentType = MediaTypeHeaderValue.Parse("application/json") },
|
||||
});
|
||||
var output = await resp.Content.ReadAsStringAsync();
|
||||
PluginLog.Log(output);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
using Dalamud.Game;
|
||||
using Dalamud.Game.Gui.PartyFinder;
|
||||
using Dalamud.IoC;
|
||||
using Dalamud.Plugin;
|
||||
|
||||
namespace RemotePartyFinder {
|
||||
public class Plugin : IDalamudPlugin {
|
||||
public string Name => "Remote Party Finder";
|
||||
|
||||
[PluginService]
|
||||
internal Framework Framework { get; private init; }
|
||||
|
||||
[PluginService]
|
||||
internal PartyFinderGui PartyFinderGui { get; private init; }
|
||||
|
||||
private Gatherer Gatherer { get; }
|
||||
|
||||
public Plugin() {
|
||||
this.Gatherer = new Gatherer(this);
|
||||
}
|
||||
|
||||
public void Dispose() {
|
||||
this.Gatherer.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<Version>1.0.1</Version>
|
||||
<TargetFramework>net5.0-windows</TargetFramework>
|
||||
<ProduceReferenceAssembly>false</ProduceReferenceAssembly>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<Dalamud>$(AppData)\XIVLauncher\addon\Hooks\dev</Dalamud>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Reference Include="Dalamud">
|
||||
<HintPath>$(Dalamud)\Dalamud.dll</HintPath>
|
||||
<Private>false</Private>
|
||||
</Reference>
|
||||
<Reference Include="Lumina">
|
||||
<HintPath>$(Dalamud)\Lumina.dll</HintPath>
|
||||
<Private>false</Private>
|
||||
</Reference>
|
||||
<Reference Include="Lumina.Excel">
|
||||
<HintPath>$(Dalamud)\Lumina.Excel.dll</HintPath>
|
||||
<Private>false</Private>
|
||||
</Reference>
|
||||
<Reference Include="Newtonsoft.Json">
|
||||
<HintPath>$(Dalamud)\Newtonsoft.Json.dll</HintPath>
|
||||
<Private>false</Private>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="DalamudLinter" Version="1.0.3"/>
|
||||
<PackageReference Include="DalamudPackager" Version="2.1.3"/>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
|
@ -0,0 +1,11 @@
|
|||
author: ascclemens
|
||||
name: Remote Party Finder Uploader
|
||||
description: |-
|
||||
Uploads the PF listings you retrieve to the crowdsourced Remote
|
||||
Party Finder website (https://rpf.annaclemens.io/).
|
||||
|
||||
THIS IS BETA AF AND DEFINITELY NOT PRODUCTION QUALITY
|
||||
|
||||
PLEASE NO REPORT SHIT
|
||||
punchline: '[Extreme Beta] Crowdsourced PF website'
|
||||
repo_url: https://git.sr.ht/~jkcclemens/RemotePartyFinder
|
|
@ -0,0 +1,72 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Dalamud.Game.Gui.PartyFinder.Types;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Serialization;
|
||||
|
||||
namespace RemotePartyFinder {
|
||||
[Serializable]
|
||||
[JsonObject(NamingStrategyType = typeof(SnakeCaseNamingStrategy))]
|
||||
internal class UploadableListing {
|
||||
public uint Id { get; }
|
||||
public uint ContentIdLower { get; }
|
||||
public byte[] Name { get; }
|
||||
public byte[] Description { get; }
|
||||
public byte CreatedWorld { get; }
|
||||
public byte HomeWorld { get; }
|
||||
public byte CurrentWorld { get; }
|
||||
public DutyCategory Category { get; }
|
||||
public ushort Duty { get; }
|
||||
public DutyType DutyType { get; }
|
||||
public bool BeginnersWelcome { get; }
|
||||
public ushort SecondsRemaining { get; }
|
||||
public ushort MinItemLevel { get; }
|
||||
public byte NumParties { get; }
|
||||
public byte SlotsAvailable { get; }
|
||||
public uint LastServerRestart { get; }
|
||||
public ObjectiveFlags Objective { get; }
|
||||
public ConditionFlags Conditions { get; }
|
||||
public DutyFinderSettingsFlags DutyFinderSettings { get; }
|
||||
public LootRuleFlags LootRules { get; }
|
||||
public SearchAreaFlags SearchArea { get; }
|
||||
public List<UploadableSlot> Slots { get; }
|
||||
public List<byte> JobsPresent { get; }
|
||||
|
||||
internal UploadableListing(PartyFinderListing listing) {
|
||||
this.Id = listing.Id;
|
||||
this.ContentIdLower = listing.ContentIdLower;
|
||||
this.Name = listing.Name.Encode();
|
||||
this.Description = listing.Description.Encode();
|
||||
this.CreatedWorld = (byte) listing.World.Value.RowId;
|
||||
this.HomeWorld = (byte) listing.HomeWorld.Value.RowId;
|
||||
this.CurrentWorld = (byte) listing.CurrentWorld.Value.RowId;
|
||||
this.Category = listing.Category;
|
||||
this.Duty = listing.RawDuty;
|
||||
this.DutyType = listing.DutyType;
|
||||
this.BeginnersWelcome = listing.BeginnersWelcome;
|
||||
this.SecondsRemaining = listing.SecondsRemaining;
|
||||
this.MinItemLevel = listing.MinimumItemLevel;
|
||||
this.NumParties = listing.Parties;
|
||||
this.SlotsAvailable = listing.SlotsAvailable;
|
||||
this.LastServerRestart = listing.LastPatchHotfixTimestamp;
|
||||
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(slot => new UploadableSlot(slot)).ToList();
|
||||
this.JobsPresent = listing.RawJobsPresent.ToList();
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
[JsonObject(NamingStrategyType = typeof(SnakeCaseNamingStrategy))]
|
||||
internal class UploadableSlot {
|
||||
public JobFlags Accepting { get; }
|
||||
|
||||
internal UploadableSlot(PartyFinderSlot slot) {
|
||||
this.Accepting = slot.Accepting.Aggregate((JobFlags) 0, ((agg, flag) => agg | flag));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,290 @@
|
|||
using System.IO;
|
||||
using System.Text;
|
||||
using Lumina;
|
||||
using Lumina.Excel.GeneratedSheets;
|
||||
|
||||
namespace SourceGenerator {
|
||||
internal class Program {
|
||||
private static void Main(string[] args) {
|
||||
var data = new GameData(args[0]);
|
||||
var prog = new Program(data);
|
||||
|
||||
File.WriteAllText(Path.Join(args[1], "duties.rs"), prog.GenerateDuties());
|
||||
File.WriteAllText(Path.Join(args[1], "jobs.rs"), prog.GenerateJobs());
|
||||
File.WriteAllText(Path.Join(args[1], "roulettes.rs"), prog.GenerateRoulettes());
|
||||
File.WriteAllText(Path.Join(args[1], "worlds.rs"), prog.GenerateWorlds());
|
||||
File.WriteAllText(Path.Join(args[1], "territory_names.rs"), prog.GenerateTerritoryNames());
|
||||
File.WriteAllText(Path.Join(args[1], "auto_translate.rs"), prog.GenerateAutoTranslate());
|
||||
File.WriteAllText(Path.Join(args[1], "treasure_maps.rs"), prog.GenerateTreasureMaps());
|
||||
}
|
||||
|
||||
private GameData Data { get; }
|
||||
|
||||
private Program(GameData data) {
|
||||
this.Data = data;
|
||||
}
|
||||
|
||||
private static StringBuilder DefaultHeader() {
|
||||
return new StringBuilder("use std::collections::HashMap;\n");
|
||||
}
|
||||
|
||||
private string GenerateDuties() {
|
||||
var sb = DefaultHeader();
|
||||
sb.Append('\n');
|
||||
|
||||
sb.Append("#[derive(Debug)]\n");
|
||||
sb.Append("pub struct DutyInfo {\n");
|
||||
sb.Append(" pub name: &'static str,\n");
|
||||
sb.Append(" pub high_end: bool,\n");
|
||||
sb.Append(" pub content_kind: ContentKind,\n");
|
||||
sb.Append("}\n\n");
|
||||
|
||||
sb.Append("#[derive(Debug, Clone, Copy)]\n");
|
||||
sb.Append("#[allow(unused)]\n");
|
||||
sb.Append("#[repr(u32)]\n");
|
||||
sb.Append("pub enum ContentKind {\n");
|
||||
foreach (var kind in this.Data.GetExcelSheet<ContentType>()!) {
|
||||
var name = kind.Name.TextValue().Replace(" ", "");
|
||||
if (name.Length > 0) {
|
||||
sb.Append($" {name} = {kind.RowId},\n");
|
||||
}
|
||||
}
|
||||
|
||||
sb.Append(" Other(u32),\n");
|
||||
sb.Append("}\n\n");
|
||||
|
||||
sb.Append("impl ContentKind {\n");
|
||||
|
||||
sb.Append(" fn from_u32(kind: u32) -> Self {\n");
|
||||
sb.Append(" match kind {\n");
|
||||
foreach (var kind in this.Data.GetExcelSheet<ContentType>()!) {
|
||||
var name = kind.Name.TextValue().Replace(" ", "");
|
||||
if (name.Length > 0) {
|
||||
sb.Append($" {kind.RowId} => Self::{name},\n");
|
||||
}
|
||||
}
|
||||
|
||||
sb.Append(" x => Self::Other(x),\n");
|
||||
sb.Append(" }\n");
|
||||
sb.Append(" }\n\n");
|
||||
|
||||
sb.Append(" pub fn as_u32(self) -> u32 {\n");
|
||||
sb.Append(" match self {\n");
|
||||
foreach (var kind in this.Data.GetExcelSheet<ContentType>()!) {
|
||||
var name = kind.Name.TextValue().Replace(" ", "");
|
||||
if (name.Length > 0) {
|
||||
sb.Append($" Self::{name} => {kind.RowId},\n");
|
||||
}
|
||||
}
|
||||
|
||||
sb.Append(" Self::Other(x) => x,\n");
|
||||
sb.Append(" }\n");
|
||||
sb.Append(" }\n");
|
||||
|
||||
sb.Append("}\n\n");
|
||||
|
||||
sb.Append("lazy_static::lazy_static! {\n");
|
||||
sb.Append(" pub static ref DUTIES: HashMap<u32, DutyInfo> = maplit::hashmap! {\n");
|
||||
|
||||
foreach (var cfc in this.Data.GetExcelSheet<ContentFinderCondition>()!) {
|
||||
if (cfc.RowId == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
var name = cfc.Name.TextValue();
|
||||
if (name.Length <= 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
name = name[..1].ToUpperInvariant() + name[1..];
|
||||
var highEnd = cfc.HighEndDuty ? "true" : "false";
|
||||
var contentType = cfc.ContentType.Value;
|
||||
var contentKind = contentType?.Name?.TextValue()?.Replace(" ", "");
|
||||
if (string.IsNullOrEmpty(contentKind)) {
|
||||
contentKind = $"Other({contentType?.RowId ?? 0})";
|
||||
}
|
||||
|
||||
sb.Append($" {cfc.RowId} => DutyInfo {{\n");
|
||||
sb.Append($" name: \"{name}\",\n");
|
||||
sb.Append($" high_end: {highEnd},\n");
|
||||
sb.Append($" content_kind: ContentKind::{contentKind},\n");
|
||||
sb.Append(" },\n");
|
||||
}
|
||||
|
||||
sb.Append(" };\n");
|
||||
sb.Append("}\n");
|
||||
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
private string GenerateJobs() {
|
||||
var sb = DefaultHeader();
|
||||
sb.Append("use ffxiv_types::jobs::{ClassJob, Class, Job, NonCombatJob};\n\n");
|
||||
sb.Append("lazy_static::lazy_static! {\n");
|
||||
sb.Append(" pub static ref JOBS: HashMap<u32, ClassJob> = maplit::hashmap! {\n");
|
||||
|
||||
foreach (var cj in this.Data.GetExcelSheet<ClassJob>()!) {
|
||||
if (cj.RowId == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
var name = cj.NameEnglish.TextValue().Replace(" ", "");
|
||||
if (name.Length <= 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
var isCombat = cj.Role != 0;
|
||||
var isClass = cj.JobIndex == 0;
|
||||
|
||||
string value;
|
||||
if (isCombat) {
|
||||
value = isClass
|
||||
? $"ClassJob::Class(Class::{name})"
|
||||
: $"ClassJob::Job(Job::{name})";
|
||||
} else {
|
||||
value = $"ClassJob::NonCombat(NonCombatJob::{name})";
|
||||
}
|
||||
|
||||
sb.Append($" {cj.RowId} => {value},\n");
|
||||
}
|
||||
|
||||
sb.Append(" };\n");
|
||||
sb.Append("}\n");
|
||||
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
private string GenerateRoulettes() {
|
||||
var sb = DefaultHeader();
|
||||
sb.Append('\n');
|
||||
sb.Append("#[derive(Debug)]\n");
|
||||
sb.Append("pub struct RouletteInfo {\n");
|
||||
sb.Append(" pub name: &'static str,\n");
|
||||
sb.Append(" pub pvp: bool,\n");
|
||||
sb.Append("}\n\n");
|
||||
|
||||
sb.Append("lazy_static::lazy_static! {\n");
|
||||
sb.Append(" pub static ref ROULETTES: HashMap<u32, RouletteInfo> = maplit::hashmap! {\n");
|
||||
|
||||
foreach (var cr in this.Data.GetExcelSheet<ContentRoulette>()!) {
|
||||
if (cr.RowId == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
var name = cr.Name.TextValue();
|
||||
if (name.Length <= 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
var pvp = cr.Unknown28 == 6
|
||||
? "true"
|
||||
: "false";
|
||||
|
||||
sb.Append($" {cr.RowId} => RouletteInfo {{\n");
|
||||
sb.Append($" name: \"{name}\",\n");
|
||||
sb.Append($" pvp: {pvp},\n");
|
||||
sb.Append(" },\n");
|
||||
}
|
||||
|
||||
sb.Append(" };\n");
|
||||
sb.Append("}\n");
|
||||
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
private string GenerateWorlds() {
|
||||
var sb = DefaultHeader();
|
||||
sb.Append("use ffxiv_types::World;\n\n");
|
||||
sb.Append("lazy_static::lazy_static! {\n");
|
||||
sb.Append(" pub static ref WORLDS: HashMap<u32, World> = maplit::hashmap! {\n");
|
||||
|
||||
foreach (var world in this.Data.GetExcelSheet<World>()!) {
|
||||
if (world.RowId == 0 || !world.IsPublic || world.DataCenter.Row == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
var name = world.Name.TextValue();
|
||||
if (name.Length <= 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
sb.Append($" {world.RowId} => World::{name},\n");
|
||||
}
|
||||
|
||||
sb.Append(" };\n");
|
||||
sb.Append("}\n");
|
||||
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
private string GenerateTerritoryNames() {
|
||||
var sb = DefaultHeader();
|
||||
sb.Append("\nlazy_static::lazy_static! {\n");
|
||||
sb.Append(" pub static ref TERRITORY_NAMES: HashMap<u32, &'static str> = maplit::hashmap! {\n");
|
||||
|
||||
foreach (var tt in this.Data.GetExcelSheet<TerritoryType>()!) {
|
||||
if (tt.RowId == 0 || tt.PlaceName.Row == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
var name = tt.PlaceName.Value!.Name.TextValue().Replace("\"", "\\\"");
|
||||
if (name.Length <= 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
sb.Append($" {tt.RowId} => \"{name}\",\n");
|
||||
}
|
||||
|
||||
sb.Append(" };\n");
|
||||
sb.Append("}\n");
|
||||
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
private string GenerateAutoTranslate() {
|
||||
var sb = DefaultHeader();
|
||||
sb.Append("\nlazy_static::lazy_static! {\n");
|
||||
sb.Append(" pub static ref AUTO_TRANSLATE: HashMap<(u32, u32), &'static str> = maplit::hashmap! {\n");
|
||||
|
||||
foreach (var row in this.Data.GetExcelSheet<Completion>()!) {
|
||||
var lookup = row.LookupTable.TextValue();
|
||||
if (lookup is not ("" or "@")) {
|
||||
// TODO: do lookup
|
||||
} else {
|
||||
var text = row.Text.TextValue();
|
||||
sb.Append($" ({row.Group}, {row.RowId}) => \"{text}\",\n");
|
||||
}
|
||||
}
|
||||
|
||||
sb.Append(" };\n");
|
||||
sb.Append("}\n");
|
||||
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
private string GenerateTreasureMaps() {
|
||||
var sb = DefaultHeader();
|
||||
sb.Append("\nlazy_static::lazy_static! {\n");
|
||||
sb.Append(" pub static ref TREASURE_MAPS: HashMap<u32, &'static str> = maplit::hashmap! {\n");
|
||||
sb.Append(" 0 => \"All Levels\",\n");
|
||||
|
||||
var i = 1;
|
||||
foreach (var row in this.Data.GetExcelSheet<TreasureHuntRank>()!) {
|
||||
// IS THIS RIGHT?
|
||||
if (row.TreasureHuntTexture != 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
var name = row.KeyItemName.Value?.Name.TextValue();
|
||||
if (!string.IsNullOrEmpty(name)) {
|
||||
sb.Append($" {i++} => \"{name}\",\n");
|
||||
}
|
||||
}
|
||||
|
||||
sb.Append(" };\n");
|
||||
sb.Append("}\n");
|
||||
|
||||
return sb.ToString();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
using System.Linq;
|
||||
using Lumina.Text;
|
||||
using Lumina.Text.Payloads;
|
||||
|
||||
namespace SourceGenerator {
|
||||
internal static class SeStringExtensions {
|
||||
internal static string TextValue(this SeString str) {
|
||||
var payloads = str.Payloads
|
||||
.Select(p => {
|
||||
if (p is TextPayload text) {
|
||||
return text.RawString;
|
||||
}
|
||||
|
||||
return p.Data.Length > 1 && p.Data[1] == 0x1F ? "-" : "";
|
||||
});
|
||||
// Produces:
|
||||
// MainCommand[col-,1-36,41-42,44-44,56-62,64-70,72-82,84-99]
|
||||
// TextCommand[col-,col-,1-31,33-211,213-321,323-455,459-611,613-629,632-632]
|
||||
// TextCommand[col-,col-,1-31,33-211,213-321,323-455,459-611,613-629,632-632]
|
||||
// Pet[,1-8,10-10,14-15,17-19]
|
||||
// PetMirage[col-♥]
|
||||
//
|
||||
// foreach (var payload in str.Payloads) {
|
||||
// if (payload is TextPayload) {
|
||||
// continue;
|
||||
// }
|
||||
//
|
||||
// if (payload.Data.Length > 1 && payload.Data[1] == 0x20) {
|
||||
// Console.WriteLine(string.Join("", payloads));
|
||||
// }
|
||||
// }
|
||||
|
||||
return string.Join("", payloads);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Lumina" Version="3.4.0" />
|
||||
<PackageReference Include="Lumina.Excel" Version="5.50.0" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
Before Width: | Height: | Size: 64 KiB After Width: | Height: | Size: 64 KiB |
Loading…
Reference in New Issue