chore: initial commit

This commit is contained in:
Anna 2021-03-21 01:48:48 -04:00
commit 8039d8f4d5
Signed by: anna
GPG Key ID: 0B391D8F06FCD9E0
15 changed files with 1252 additions and 0 deletions

365
.gitignore vendored Normal file
View File

@ -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

16
Tourist.sln Executable file
View File

@ -0,0 +1,16 @@

Microsoft Visual Studio Solution File, Format Version 12.00
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tourist", "Tourist\Tourist.csproj", "{EBAF1BDC-2509-4504-8A4B-ED9C563FBEB6}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{EBAF1BDC-2509-4504-8A4B-ED9C563FBEB6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EBAF1BDC-2509-4504-8A4B-ED9C563FBEB6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EBAF1BDC-2509-4504-8A4B-ED9C563FBEB6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EBAF1BDC-2509-4504-8A4B-ED9C563FBEB6}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal

24
Tourist/Commands.cs Executable file
View File

@ -0,0 +1,24 @@
using System;
using Dalamud.Game.Command;
namespace Tourist {
public class Commands : IDisposable {
private Plugin Plugin { get; }
public Commands(Plugin plugin) {
this.Plugin = plugin;
this.Plugin.Interface.CommandManager.AddHandler("/tourist", new CommandInfo(this.OnCommand) {
HelpMessage = "Opens the Tourist interface",
});
}
public void Dispose() {
this.Plugin.Interface.CommandManager.RemoveHandler("/tourist");
}
private void OnCommand(string command, string arguments) {
this.Plugin.Ui.Show = !this.Plugin.Ui.Show;
}
}
}

26
Tourist/Configuration.cs Executable file
View File

@ -0,0 +1,26 @@
using System;
using Dalamud.Configuration;
namespace Tourist {
[Serializable]
public class Configuration : IPluginConfiguration {
private Plugin Plugin { get; set; } = null!;
public int Version { get; set; } = 1;
public bool ShowFinished { get; set; } = true;
public bool ShowUnavailable { get; set; } = true;
public bool ShowArrVistas { get; set; } = true;
public bool OnlyShowCurrentZone { get; set; }
public bool ShowTimeUntilAvailable { get; set; } = true;
public bool ShowTimeLeft { get; set; } = true;
internal void Initialise(Plugin plugin) {
this.Plugin = plugin;
}
internal void Save() {
this.Plugin.Interface.SavePluginConfig(this);
}
}
}

15
Tourist/DalamudPackager.targets Executable file
View File

@ -0,0 +1,15 @@
<Project>
<Target Name="PackagePlugin" AfterTargets="Build" Condition="'$(Configuration)' == 'Release'">
<DalamudPackager
ProjectDir="$(ProjectDir)"
OutputPath="$(OutputPath)"
AssemblyName="$(AssemblyName)"
VersionComponents="3"
MakeZip="true"
Include="
Tourist.dll;
Tourist.pdb;
Tourist.json
"/>
</Target>
</Project>

7
Tourist/FodyWeavers.xml Executable file
View File

@ -0,0 +1,7 @@
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd">
<Costura>
<IncludeAssemblies>
FFXIVWeather.Lumina
</IncludeAssemblies>
</Costura>
</Weavers>

90
Tourist/GameFunctions.cs Executable file
View File

@ -0,0 +1,90 @@
using System;
using System.Numerics;
using System.Runtime.InteropServices;
using Dalamud.Hooking;
namespace Tourist {
public class GameFunctions : IDisposable {
private delegate IntPtr VistaUnlockedDelegate(ushort index, int a2, int a3);
private delegate IntPtr CreateVfxDelegate(string name);
private delegate IntPtr PlayVfxDelegate(IntPtr vfx, float idk, int idk2);
internal delegate IntPtr RemoveVfxDelegate(IntPtr vfx);
private Plugin Plugin { get; }
private IntPtr SightseeingMaskPointer { get; }
private CreateVfxDelegate CreateVfx { get; }
private PlayVfxDelegate PlayVfxInternal { get; }
internal RemoveVfxDelegate RemoveVfx { get; }
private Hook<VistaUnlockedDelegate> VistaUnlockedHook { get; }
public GameFunctions(Plugin plugin) {
this.Plugin = plugin;
var vistaUnlockedPtr = this.Plugin.Interface.TargetModuleScanner.ScanText("E8 ?? ?? ?? ?? E9 ?? ?? ?? ?? 41 8B CD E8 ?? ?? ?? ??");
this.VistaUnlockedHook = new Hook<VistaUnlockedDelegate>(vistaUnlockedPtr, new VistaUnlockedDelegate(this.OnVistaUnlock));
this.VistaUnlockedHook.Enable();
var maskPtr = this.Plugin.Interface.TargetModuleScanner.GetStaticAddressFromSig("8B F2 48 8D 0D ?? ?? ?? ?? 8B D3");
this.SightseeingMaskPointer = maskPtr;
var createVfxPtr = this.Plugin.Interface.TargetModuleScanner.ScanText("E8 ?? ?? ?? ?? F3 0F 10 35 ?? ?? ?? ?? 48 89 43 08");
this.CreateVfx = Marshal.GetDelegateForFunctionPointer<CreateVfxDelegate>(createVfxPtr);
var playVfxPtr = this.Plugin.Interface.TargetModuleScanner.ScanText("E8 ?? ?? ?? ?? 8B 4B 7C 85 C9");
this.PlayVfxInternal = Marshal.GetDelegateForFunctionPointer<PlayVfxDelegate>(playVfxPtr);
var removeVfxPtr = this.Plugin.Interface.TargetModuleScanner.ScanText("40 53 48 83 EC 20 48 8B D9 48 8B 89 ?? ?? ?? ?? 48 85 C9 74 28 33 D2");
this.RemoveVfx = Marshal.GetDelegateForFunctionPointer<RemoveVfxDelegate>(removeVfxPtr);
}
public void Dispose() {
this.VistaUnlockedHook.Dispose();
}
private IntPtr OnVistaUnlock(ushort index, int a2, int a3) {
this.Plugin.Markers.RemoveVfx(index);
return this.VistaUnlockedHook.Original(index, a2, a3);
}
public unsafe IntPtr SpawnVfx(string name, Vector3 position) {
var vfx = this.CreateVfx(name);
var pos = (float*) (vfx + 80);
*pos = position.X;
*(pos + 1) = position.Z;
*(pos + 2) = position.Y;
pos = (float*) (vfx + 640);
*pos = 0;
*(pos + 1) = 0;
*(pos + 2) = 0;
*(long*) (vfx + 56) |= 2;
*(int*) (vfx + 652) = 0;
return vfx;
}
internal bool PlayVfx(IntPtr vfx) {
return this.PlayVfxInternal(vfx, 0.0f, -1) == IntPtr.Zero;
}
public bool HasVistaUnlocked(short index) {
if (this.SightseeingMaskPointer == IntPtr.Zero) {
return false;
}
var byteToCheck = index >> 3;
var bitToCheck = 1 << (index - 8 * byteToCheck);
var maskPart = Marshal.ReadByte(this.SightseeingMaskPointer + byteToCheck);
return (maskPart & bitToCheck) != 0;
}
}
}

97
Tourist/Markers.cs Executable file
View File

@ -0,0 +1,97 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using Dalamud.Game.Internal;
using Lumina.Excel.GeneratedSheets;
namespace Tourist {
public class Markers : IDisposable {
private const string MarkerPath = "bgcommon/world/common/vfx_for_live/eff/b0810_tnsk_y.avfx";
private Plugin Plugin { get; }
private Dictionary<uint, IntPtr> Spawned { get; } = new();
private HashSet<IntPtr> Queue { get; } = new();
public Markers(Plugin plugin) {
this.Plugin = plugin;
this.Plugin.Interface.ClientState.TerritoryChanged += this.OnTerritoryChange;
this.Plugin.Interface.Framework.OnUpdateEvent += this.OnFrameworkUpdate;
if (this.Plugin.Config.ShowArrVistas) {
this.SpawnVfxForCurrentZone(this.Plugin.Interface.ClientState.TerritoryType);
}
}
public void Dispose() {
this.Plugin.Interface.Framework.OnUpdateEvent -= this.OnFrameworkUpdate;
this.Plugin.Interface.ClientState.TerritoryChanged -= this.OnTerritoryChange;
this.RemoveAllVfx();
}
internal void RemoveVfx(ushort index) {
var adventure = this.Plugin.Interface.Data.GetExcelSheet<Adventure>()
.Skip(index)
.First();
if (!this.Spawned.TryGetValue(adventure.RowId, out var vfx)) {
return;
}
this.Plugin.Functions.RemoveVfx(vfx);
this.Spawned.Remove(adventure.RowId);
}
internal void RemoveAllVfx() {
foreach (var vfx in this.Spawned.Values) {
this.Plugin.Functions.RemoveVfx(vfx);
}
this.Spawned.Clear();
}
internal void SpawnVfxForCurrentZone(ushort territory) {
var row = 0;
foreach (var adventure in this.Plugin.Interface.Data.GetExcelSheet<Adventure>()) {
if (row >= 80) {
break;
}
row += 1;
if (adventure.Level.Value.Territory.Row != territory) {
continue;
}
if (this.Plugin.Functions.HasVistaUnlocked((short) (row - 1))) {
continue;
}
var loc = adventure.Level.Value;
var pos = new Vector3(loc.X, loc.Z, loc.Y + 0.5f);
var vfx = this.Plugin.Functions.SpawnVfx(MarkerPath, pos);
this.Spawned[adventure.RowId] = vfx;
this.Queue.Add(vfx);
}
}
private void OnTerritoryChange(object sender, ushort territory) {
if (!this.Plugin.Config.ShowArrVistas) {
return;
}
this.RemoveAllVfx();
this.SpawnVfxForCurrentZone(territory);
}
private void OnFrameworkUpdate(Framework framework) {
foreach (var vfx in this.Queue.ToArray()) {
if (this.Plugin.Functions.PlayVfx(vfx)) {
this.Queue.Remove(vfx);
}
}
}
}
}

49
Tourist/Plugin.cs Executable file
View File

@ -0,0 +1,49 @@
using System;
using System.Reflection;
using Dalamud.Plugin;
using FFXIVWeather.Lumina;
namespace Tourist {
// ReSharper disable once ClassNeverInstantiated.Global
public class Plugin : IDalamudPlugin {
public string Name => "Tourist";
internal DalamudPluginInterface Interface { get; private set; } = null!;
internal Configuration Config { get; private set; } = null!;
internal PluginUi Ui { get; set; } = null!;
internal FFXIVWeatherLuminaService Weather { get; private set; } = null!;
internal GameFunctions Functions { get; private set; } = null!;
private Commands Commands { get; set; } = null!;
internal Markers Markers { get; set; } = null!;
public void Initialize(DalamudPluginInterface pluginInterface) {
this.Interface = pluginInterface;
this.Config = this.Interface.GetPluginConfig() as Configuration ?? new Configuration();
this.Config.Initialise(this);
var gameDataField = this.Interface.Data.GetType().GetField("gameData", BindingFlags.Instance | BindingFlags.NonPublic);
if (gameDataField == null) {
throw new Exception("Missing gameData field");
}
var lumina = (Lumina.Lumina) gameDataField.GetValue(this.Interface.Data);
this.Weather = new FFXIVWeatherLuminaService(lumina);
this.Functions = new GameFunctions(this);
this.Markers = new Markers(this);
this.Ui = new PluginUi(this);
this.Commands = new Commands(this);
}
public void Dispose() {
this.Commands.Dispose();
this.Ui.Dispose();
this.Markers.Dispose();
this.Functions.Dispose();
}
}
}

203
Tourist/PluginUi.cs Executable file
View File

@ -0,0 +1,203 @@
using System;
using System.Linq;
using System.Numerics;
using ImGuiNET;
using Lumina.Excel.GeneratedSheets;
namespace Tourist {
public class PluginUi : IDisposable {
private Plugin Plugin { get; }
private bool _show;
internal bool Show {
get => this._show;
set => this._show = value;
}
public PluginUi(Plugin plugin) {
this.Plugin = plugin;
this.Plugin.Interface.UiBuilder.OnBuildUi += this.Draw;
this.Plugin.Interface.UiBuilder.OnOpenConfigUi += this.OpenConfig;
}
public void Dispose() {
this.Plugin.Interface.UiBuilder.OnOpenConfigUi -= this.OpenConfig;
this.Plugin.Interface.UiBuilder.OnBuildUi -= this.Draw;
}
private void OpenConfig(object sender, EventArgs eventArgs) {
this.Show = true;
}
private void Draw() {
ImGui.SetNextWindowSize(new Vector2(350f, 450f), ImGuiCond.FirstUseEver);
if (!this.Show || !ImGui.Begin(this.Plugin.Name, ref this._show, ImGuiWindowFlags.MenuBar)) {
return;
}
if (ImGui.BeginMenuBar()) {
if (ImGui.BeginMenu("Options")) {
if (ImGui.BeginMenu("Times")) {
var showTimeUntil = this.Plugin.Config.ShowTimeUntilAvailable;
if (ImGui.MenuItem("Show time until available", null, ref showTimeUntil)) {
this.Plugin.Config.ShowTimeUntilAvailable = showTimeUntil;
this.Plugin.Config.Save();
}
var showTimeLeft = this.Plugin.Config.ShowTimeLeft;
if (ImGui.MenuItem("Show time left", null, ref showTimeLeft)) {
this.Plugin.Config.ShowTimeLeft = showTimeLeft;
this.Plugin.Config.Save();
}
ImGui.EndMenu();
}
var showFinished = this.Plugin.Config.ShowFinished;
if (ImGui.MenuItem("Show finished", null, ref showFinished)) {
this.Plugin.Config.ShowFinished = showFinished;
this.Plugin.Config.Save();
}
var showUnavailable = this.Plugin.Config.ShowUnavailable;
if (ImGui.MenuItem("Show unavailable", null, ref showUnavailable)) {
this.Plugin.Config.ShowUnavailable = showUnavailable;
this.Plugin.Config.Save();
}
var showArrVistas = this.Plugin.Config.ShowArrVistas;
if (ImGui.MenuItem("Add markers for ARR vistas", null, ref showArrVistas)) {
this.Plugin.Config.ShowArrVistas = showArrVistas;
this.Plugin.Config.Save();
if (showArrVistas) {
var territory = this.Plugin.Interface.ClientState.TerritoryType;
this.Plugin.Markers.SpawnVfxForCurrentZone(territory);
} else {
this.Plugin.Markers.RemoveAllVfx();
}
}
var onlyCurrent = this.Plugin.Config.OnlyShowCurrentZone;
if (ImGui.MenuItem("Only show vistas for current zone", null, ref onlyCurrent)) {
this.Plugin.Config.OnlyShowCurrentZone = onlyCurrent;
this.Plugin.Config.Save();
}
ImGui.EndMenu();
}
if (ImGui.BeginMenu("Help")) {
ImGui.PushTextWrapPos(ImGui.GetFontSize() * 10);
ImGui.TextUnformatted("Vistas 21 to 80 require the completion of the first 20. Talk to Millith Ironheart in Old Gridania to unlock the rest.");
ImGui.PopTextWrapPos();
ImGui.EndMenu();
}
ImGui.EndMenuBar();
}
if (ImGui.BeginChild("tourist-adventures", new Vector2(0, 0))) {
var adventures = this.Plugin.Interface.Data.GetExcelSheet<Adventure>();
var row = 0;
foreach (var adventure in adventures) {
var idx = row;
row += 1;
if (this.Plugin.Config.OnlyShowCurrentZone && adventure.Level.Value.Territory.Row != this.Plugin.Interface.ClientState.TerritoryType) {
continue;
}
var has = this.Plugin.Functions.HasVistaUnlocked((short) idx);
if (!this.Plugin.Config.ShowFinished && has) {
continue;
}
var available = adventure.Available(this.Plugin.Weather);
if (!this.Plugin.Config.ShowUnavailable && !available) {
continue;
}
var availability = adventure.NextAvailable(this.Plugin.Weather);
DateTimeOffset? countdown = null;
if (has) {
ImGui.PushStyleColor(ImGuiCol.Text, new Vector4(0.8f, 0.8f, 0.8f, 1f));
} else if (available) {
ImGui.PushStyleColor(ImGuiCol.Text, new Vector4(0f, 1f, 0f, 1f));
if (this.Plugin.Config.ShowTimeLeft) {
countdown = availability?.end;
}
} else if (availability != null && this.Plugin.Config.ShowTimeUntilAvailable) {
countdown = availability.Value.start;
}
var next = countdown == null
? string.Empty
: $" ({(countdown.Value - DateTimeOffset.UtcNow).ToHumanReadable()})";
var name = this.Plugin.Interface.SeStringManager.Parse(adventure.Name.RawData.ToArray());
var header = ImGui.CollapsingHeader($"#{row} - {name.TextValue}{next}###adventure-{adventure.RowId}");
if (has || available) {
ImGui.PopStyleColor();
}
if (!header) {
continue;
}
ImGui.Columns(2);
ImGui.SetColumnWidth(0, ImGui.CalcTextSize("Eorzea time").X + ImGui.GetStyle().ItemSpacing.X * 2);
ImGui.TextUnformatted("Command");
ImGui.NextColumn();
ImGui.TextUnformatted(adventure.Emote.Value.TextCommand.Value.Command);
ImGui.NextColumn();
ImGui.TextUnformatted("Eorzea time");
ImGui.NextColumn();
if (adventure.MinTime != 0 && adventure.MaxTime != 0) {
ImGui.TextUnformatted($"{adventure.MinTime / 100:00}:00 to {adventure.MaxTime / 100 + 1:00}:00");
} else {
ImGui.TextUnformatted("Any");
}
ImGui.NextColumn();
ImGui.TextUnformatted("Weather");
ImGui.NextColumn();
if (Weathers.All.TryGetValue(adventure.RowId, out var weathers)) {
var weatherString = string.Join(", ", weathers
.OrderBy(id => id)
.Select(id => this.Plugin.Interface.Data.GetExcelSheet<Weather>().GetRow(id))
.Select(weather => weather.Name));
ImGui.TextUnformatted(weatherString);
} else {
ImGui.TextUnformatted("Any");
}
ImGui.Columns();
if (ImGui.Button($"Open map##{adventure.RowId}")) {
this.Plugin.Interface.OpenMapLocation(adventure);
}
}
ImGui.EndChild();
}
ImGui.End();
}
}
}

51
Tourist/Tourist.csproj Executable file
View File

@ -0,0 +1,51 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Version>1.1.0</Version>
<TargetFramework>net48</TargetFramework>
<LangVersion>latest</LangVersion>
<Nullable>enable</Nullable>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<ItemGroup>
<Reference Include="Dalamud, Version=5.2.3.3, Culture=neutral, PublicKeyToken=null">
<HintPath>$(AppData)\XIVLauncher\addon\Hooks\dev\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\dev\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\dev\ImGuiScene.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Lumina, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>$(AppData)\XIVLauncher\addon\Hooks\dev\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\dev\Lumina.Excel.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="System.Memory, Version=4.0.1.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51">
<HintPath>C:\Users\Anna\AppData\Roaming\XIVLauncher\addon\Hooks\dev\System.Memory.dll</HintPath>
<Private>False</Private>
</Reference>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Costura.Fody" Version="5.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="DalamudPackager" Version="1.2.0" />
<PackageReference Include="FFXIVWeather.Lumina" Version="1.1.1" />
<PackageReference Include="Fody" Version="6.4.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
</Project>

10
Tourist/Tourist.yaml Executable file
View File

@ -0,0 +1,10 @@
name: Tourist
author: ascclemens
description: |-
Tourist adds a window to assist with the sightseeing log.
- Show when sightseeing log vistas are available
- Add markers for ARR vistas
- Open vista locations on your map
- Hide already completed or unavailable vistas
- Show the command needed for each vista

206
Tourist/Util.cs Executable file
View File

@ -0,0 +1,206 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Dalamud.Game.Chat.SeStringHandling.Payloads;
using Dalamud.Plugin;
using FFXIVWeather.Lumina;
using Lumina.Excel.GeneratedSheets;
namespace Tourist {
public static class Util {
private static Dictionary<uint, (DateTimeOffset start, DateTimeOffset end)> Availability { get; } = new();
public static void OpenMapLocation(this DalamudPluginInterface @interface, Adventure adventure) {
var loc = adventure.Level?.Value;
var map = loc?.Map?.Value;
var terr = map?.TerritoryType?.Value;
if (terr == null) {
return;
}
var x = ToMapCoordinate(loc!.X, map!.SizeFactor);
var y = ToMapCoordinate(loc.Z, map.SizeFactor);
var mapLink = new MapLinkPayload(
@interface.Data,
terr.RowId,
map.RowId,
ConvertMapCoordinateToRawPosition(x, map.SizeFactor),
ConvertMapCoordinateToRawPosition(y, map.SizeFactor)
);
@interface.Framework.Gui.OpenMapWithMapLink(mapLink);
}
private static int ConvertMapCoordinateToRawPosition(float pos, float scale) {
var c = scale / 100.0f;
var scaledPos = ((pos - 1.0f) * c / 41.0f * 2048.0f - 1024.0f) / c;
scaledPos *= 1000.0f;
return (int) scaledPos;
}
private static float ToMapCoordinate(float val, float scale) {
var c = scale / 100f;
val *= c;
return 41f / c * ((val + 1024f) / 2048f) + 1;
}
public static DateTimeOffset EorzeaTime(DateTimeOffset? at = null) {
at ??= DateTimeOffset.UtcNow;
return DateTimeOffset.FromUnixTimeMilliseconds(at.Value.ToUnixTimeMilliseconds() * 144 / 7);
}
private static DateTimeOffset EarthTime(DateTimeOffset eorzea) {
return DateTimeOffset.FromUnixTimeMilliseconds(eorzea.ToUnixTimeMilliseconds() * 7 / 144);
}
public static (DateTimeOffset start, DateTimeOffset end)? NextAvailable(this Adventure adventure, FFXIVWeatherLuminaService service) {
if (adventure.MinTime == 0 && adventure.MaxTime == 0) {
return null;
}
var actualNow = DateTimeOffset.UtcNow;
if (!Availability.ContainsKey(adventure.RowId) && adventure.Available(service)) {
var ends = adventure.AvailabilityEnds(service, DateTimeOffset.Now) ?? default;
Availability[adventure.RowId] = (DateTimeOffset.Now, ends);
}
// check the cache and use that if it's not expired
if (Availability.TryGetValue(adventure.RowId, out var cached) && cached.end >= actualNow) {
return cached;
}
var eorzea = EorzeaTime(actualNow);
// start at a clean hour
eorzea = new DateTimeOffset(eorzea.Year, eorzea.Month, eorzea.Day, eorzea.Hour, 0, 0, 0, eorzea.Offset);
var minHour = adventure.MinTime / 100;
var maxHour = adventure.MaxTime / 100 + 1;
var numHours = (24 + maxHour - minHour) % 24;
for (var i = 0; i < 10_000; i++) {
// find the next available time
var add = (minHour + 24 - eorzea.Hour) % 24;
eorzea = eorzea.AddHours(add);
// check the weather for each hour in the available range
for (var h = 0; h < numHours; h++) {
var earth = EarthTime(eorzea);
// check the weather
var offset = Math.Ceiling((earth - actualNow).TotalSeconds);
if (adventure.WeatherAvailable(service, offset)) {
// determine when the availability will end
var ends = adventure.AvailabilityEnds(service, earth) ?? default;
// cache the result of the calculation
Availability[adventure.RowId] = (earth, ends);
return (earth, ends);
}
eorzea = eorzea.AddHours(1);
}
}
return null;
}
private static DateTimeOffset? AvailabilityEnds(this Adventure adventure, FFXIVWeatherLuminaService service, DateTimeOffset starting) {
if (adventure.MinTime == 0 && adventure.MaxTime == 0) {
return null;
}
var now = starting;
var eorzea = EorzeaTime(now);
eorzea = new DateTimeOffset(eorzea.Year, eorzea.Month, eorzea.Day, eorzea.Hour, 0, 0, 0, eorzea.Offset);
now = EarthTime(eorzea);
var maxHour = adventure.MaxTime / 100 + 1;
while (eorzea.Hour != maxHour) {
if (!adventure.Available(service, eorzea)) {
return now;
}
eorzea = eorzea.AddHours(1);
now = EarthTime(eorzea);
}
return now;
}
public static bool Available(this Adventure adventure, FFXIVWeatherLuminaService service, DateTimeOffset? eorzea = null) {
var time = adventure.TimeAvailable(eorzea);
var offset = eorzea == null
? 0
: Math.Ceiling((EarthTime(eorzea.Value) - DateTimeOffset.UtcNow).TotalSeconds);
var weather = adventure.WeatherAvailable(service, offset);
return time && weather;
}
private static bool TimeAvailable(this Adventure adventure, DateTimeOffset? eorzea = null) {
if (adventure.MinTime == 0 && adventure.MaxTime == 0) {
return true;
}
eorzea ??= EorzeaTime();
var minHour = adventure.MinTime / 100;
var minMins = adventure.MinTime % 100;
var min = new TimeSpan(minHour, minMins, 0);
var maxHour = adventure.MaxTime / 100;
var maxMins = adventure.MaxTime % 100;
var max = new TimeSpan(maxHour, maxMins, 59);
var now = eorzea.Value.TimeOfDay;
if (min <= max) {
// start and stop times are in the same day
if (now >= min && now <= max) {
return true;
}
} else {
// start and stop times are in different days
if (now >= min || now <= max) {
return true;
}
}
return false;
}
private static bool WeatherAvailable(this Adventure adventure, FFXIVWeatherLuminaService service, double offset = 0d) {
if (!Weathers.All.TryGetValue(adventure.RowId, out var weathers)) {
return true;
}
var (weather, _) = service.GetCurrentWeather(adventure.Level.Value.Territory.Value, offset);
return weathers.Contains(weather.RowId);
}
public static string ToHumanReadable(this TimeSpan span) {
var hours = span.TotalDays > 0
? (int) Math.Truncate(span.TotalSeconds / 60 / 60)
: span.Hours;
var readable = new StringBuilder();
if (hours != 0) {
readable.Append($"{hours:00}:");
}
readable.Append($"{span.Minutes:00}:");
readable.Append($"{span.Seconds:00}");
return readable.ToString();
}
}
}

88
Tourist/Weathers.cs Executable file
View File

@ -0,0 +1,88 @@
using System.Collections.Generic;
namespace Tourist {
public static class Weathers {
public static readonly IReadOnlyDictionary<uint, uint[]> All = new Dictionary<uint, uint[]> {
[2162688] = new uint[] {2, 1},
[2162689] = new uint[] {1, 2},
[2162690] = new uint[] {7, 8},
[2162691] = new uint[] {2, 1},
[2162692] = new uint[] {3},
[2162693] = new uint[] {2, 1},
[2162694] = new uint[] {4},
[2162695] = new uint[] {2, 1},
[2162696] = new uint[] {3},
[2162697] = new uint[] {1, 2},
[2162698] = new uint[] {2, 1},
[2162699] = new uint[] {2, 1},
[2162700] = new uint[] {1, 2},
[2162701] = new uint[] {2, 1},
[2162702] = new uint[] {3},
[2162703] = new uint[] {2, 1},
[2162704] = new uint[] {4},
[2162705] = new uint[] {7, 8},
[2162706] = new uint[] {3},
[2162707] = new uint[] {2, 1},
[2162708] = new uint[] {2, 1},
[2162709] = new uint[] {1, 2},
[2162710] = new uint[] {7, 8},
[2162711] = new uint[] {1, 2},
[2162712] = new uint[] {7, 8},
[2162713] = new uint[] {1, 2},
[2162714] = new uint[] {6},
[2162715] = new uint[] {2, 1},
[2162716] = new uint[] {1, 2},
[2162717] = new uint[] {2, 1},
[2162718] = new uint[] {1, 2},
[2162719] = new uint[] {10},
[2162720] = new uint[] {2, 1},
[2162721] = new uint[] {3},
[2162722] = new uint[] {1, 2},
[2162723] = new uint[] {7, 8},
[2162724] = new uint[] {2, 1},
[2162725] = new uint[] {7, 8},
[2162726] = new uint[] {7, 8},
[2162727] = new uint[] {1, 2},
[2162728] = new uint[] {2, 1},
[2162729] = new uint[] {1, 2},
[2162730] = new uint[] {9},
[2162731] = new uint[] {10},
[2162732] = new uint[] {1, 2},
[2162733] = new uint[] {4},
[2162734] = new uint[] {2, 1},
[2162735] = new uint[] {2, 1},
[2162736] = new uint[] {1, 2},
[2162737] = new uint[] {3},
[2162738] = new uint[] {1, 2},
[2162739] = new uint[] {2, 1},
[2162740] = new uint[] {11},
[2162741] = new uint[] {1, 2},
[2162742] = new uint[] {1, 2},
[2162743] = new uint[] {2, 1},
[2162744] = new uint[] {8},
[2162745] = new uint[] {4},
[2162746] = new uint[] {2, 1},
[2162747] = new uint[] {14},
[2162748] = new uint[] {2, 1},
[2162749] = new uint[] {14},
[2162750] = new uint[] {1, 2},
[2162751] = new uint[] {2, 1},
[2162752] = new uint[] {2, 1},
[2162753] = new uint[] {3},
[2162754] = new uint[] {4},
[2162755] = new uint[] {1, 2},
[2162756] = new uint[] {4},
[2162757] = new uint[] {16},
[2162758] = new uint[] {2, 1},
[2162759] = new uint[] {1, 2},
[2162760] = new uint[] {16, 15},
[2162761] = new uint[] {2, 1},
[2162762] = new uint[] {2, 1},
[2162763] = new uint[] {1, 2},
[2162764] = new uint[] {17},
[2162765] = new uint[] {2, 1},
[2162766] = new uint[] {1, 2},
[2162767] = new uint[] {2, 1},
};
}
}

5
global.json Executable file
View File

@ -0,0 +1,5 @@
{
"sdk": {
"version": "5.0.103"
}
}