Skip to content

Commit

Permalink
clipboard methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Jaksuhn committed Feb 4, 2024
1 parent de928c1 commit cfbb74c
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 12 deletions.
28 changes: 23 additions & 5 deletions SomethingNeedDoing/Interface/HelpWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -328,14 +328,18 @@ static void DisplayChangelog(string date, string changes, bool separator = true)
ImGui.PushFont(UiBuilder.MonoFont);

DisplayChangelog(
"2024-02-03",
"2024-02-04",
"- Fixed the AR character query commands to only check enabled characters\n" +
"- Added PauseTextAdvance()\n" +
"- Added RestoreTextAdvance()\n" +
"- Added PandoraGetFeatureEnabled()\n" +
"- Added PandoraGetFeatureConfigEnabled()\n" +
"- Added PandoraSetFeatureState()\n" +
"- Added PandoraSetFeatureConfigState()\n" +
"- Added PandoraPauseFeature()\n");
"- Added PandoraPauseFeature()\n\n" +
"- Added GetClipboard()\n" +
"- Added SetClipboard()\n" +
"- Added CrashTheGame()\n");

DisplayChangelog(
"2024-02-01",
Expand Down Expand Up @@ -1035,11 +1039,12 @@ Lua scripts work by yielding commands back to the macro engine.
(nameof(AddonCommands), AddonCommands.Instance),
(nameof(CharacterStateCommands), CharacterStateCommands.Instance),
(nameof(CraftingCommands), CraftingCommands.Instance),
(nameof(EntityStateCommands), EntityStateCommands.Instance),
(nameof(InventoryCommands), InventoryCommands.Instance),
(nameof(IpcCommands), IpcCommands.Instance),
(nameof(QuestCommands), QuestCommands.Instance),
(nameof(EntityStateCommands), EntityStateCommands.Instance),
(nameof(WorldStateCommands), WorldStateCommands.Instance)
(nameof(SystemCommands), SystemCommands.Instance),
(nameof(WorldStateCommands), WorldStateCommands.Instance),
};

foreach (var (commandName, commandInstance) in commands)
Expand Down Expand Up @@ -1133,7 +1138,8 @@ private void DrawGameData()
("Weather", this.DrawWeather),
("CFC", this.DrawCFC),
("Duty Roulette", this.DrawDutyRoulette),
("Ocean Fishing Routes", this.DrawOceanFishingSpots),
//("Ocean Fishing Routes", this.DrawOceanFishingRoutes),
("Fishing Spots", this.DrawOceanFishingSpots),
("Achievements", this.DrawAchievements),
};

Expand Down Expand Up @@ -1181,6 +1187,18 @@ private void DrawOceanFishingSpots()
ImGui.PopStyleColor();
}

//private readonly IEnumerable<IKDRoute> fishingRoutesSheet = Svc.Data.GetExcelSheet<IKDRoute>(Svc.ClientState.ClientLanguage)!.Where(x => x.RowId != 0);
//private void DrawOceanFishingRoutes()
//{
// using var font = ImRaii.PushFont(UiBuilder.MonoFont);
// ImGui.PushStyleColor(ImGuiCol.Text, ShadedColor);
// foreach (var w in fishingRoutesSheet)
// {
// ImGui.Text($"{w.RowId}: {string.Join(" ", w.UnkData0.ToList())}");
// }
// ImGui.PopStyleColor();
//}

private readonly IEnumerable<ContentRoulette> rouletteSheet = Svc.Data.GetExcelSheet<ContentRoulette>(Svc.ClientState.ClientLanguage)!.Where(x => !x.Name.RawString.IsNullOrEmpty());
private void DrawDutyRoulette()
{
Expand Down
3 changes: 2 additions & 1 deletion SomethingNeedDoing/Misc/ActiveMacro.cs
Original file line number Diff line number Diff line change
Expand Up @@ -238,10 +238,11 @@ static void RegisterClassMethods(Lua lua, object obj)
RegisterClassMethods(this.lua, AddonCommands.Instance);
RegisterClassMethods(this.lua, CharacterStateCommands.Instance);
RegisterClassMethods(this.lua, CraftingCommands.Instance);
RegisterClassMethods(this.lua, EntityStateCommands.Instance);
RegisterClassMethods(this.lua, InventoryCommands.Instance);
RegisterClassMethods(this.lua, IpcCommands.Instance);
RegisterClassMethods(this.lua, QuestCommands.Instance);
RegisterClassMethods(this.lua, EntityStateCommands.Instance);
RegisterClassMethods(this.lua, SystemCommands.Instance);
RegisterClassMethods(this.lua, WorldStateCommands.Instance);

script = string.Format(EntrypointTemplate, script);
Expand Down
12 changes: 6 additions & 6 deletions SomethingNeedDoing/Misc/Commands/IpcCommands.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using AutoRetainerAPI;
using AutoRetainerAPI.Configuration;
using ECommons.DalamudServices;
using SomethingNeedDoing.IPC;
using System;
Expand Down Expand Up @@ -78,26 +79,25 @@ public unsafe List<string> ARGetRegisteredEnabledCharacters() =>
.Where(c => _autoRetainerApi.GetOfflineCharacterData(c).Enabled)
.Select(c => $"{_autoRetainerApi.GetOfflineCharacterData(c).Name}@{_autoRetainerApi.GetOfflineCharacterData(c).World}").ToList();

public unsafe bool ARAnyWaitingToBeProcessed(bool allCharacters = false) =>
allCharacters ?
ARRetainersWaitingToBeProcessed(allCharacters) || ARSubsWaitingToBeProcessed(allCharacters) :
ARRetainersWaitingToBeProcessed() || ARSubsWaitingToBeProcessed();
public unsafe bool ARAnyWaitingToBeProcessed(bool allCharacters = false) => ARRetainersWaitingToBeProcessed(allCharacters) || ARSubsWaitingToBeProcessed(allCharacters)

public unsafe bool ARRetainersWaitingToBeProcessed(bool allCharacters = false)
{
if (!allCharacters)
return _autoRetainerApi.GetOfflineCharacterData(Svc.ClientState.LocalContentId).RetainerData.AsParallel().Any(x => x.HasVenture && x.VentureEndsAt <= DateTime.Now.ToUnixTimestamp());
else
return _autoRetainerApi.GetRegisteredCharacters().AsParallel().Any(character => _autoRetainerApi.GetOfflineCharacterData(character).RetainerData.Any(x => x.HasVenture && x.VentureEndsAt <= DateTime.Now.ToUnixTimestamp()));
return GetAllEnabledCharacters().Any(character => _autoRetainerApi.GetOfflineCharacterData(character).RetainerData.Any(x => x.HasVenture && x.VentureEndsAt <= DateTime.Now.ToUnixTimestamp()));
}

public unsafe bool ARSubsWaitingToBeProcessed(bool allCharacters = false)
{
if (!allCharacters)
return _autoRetainerApi.GetOfflineCharacterData(Svc.ClientState.LocalContentId).OfflineSubmarineData.AsParallel().Any(x => x.ReturnTime <= DateTime.Now.ToUnixTimestamp());
else
return _autoRetainerApi.GetRegisteredCharacters().AsParallel().Any(character => _autoRetainerApi.GetOfflineCharacterData(character).OfflineSubmarineData.Any(x => x.ReturnTime <= DateTime.Now.ToUnixTimestamp()));
return GetAllEnabledCharacters().Any(c => _autoRetainerApi.GetOfflineCharacterData(c).OfflineSubmarineData.Any(x => x.ReturnTime <= DateTime.Now.ToUnixTimestamp()));
}

private unsafe ParallelQuery<ulong> GetAllEnabledCharacters() => _autoRetainerApi.GetRegisteredCharacters().AsParallel().Where(c => _autoRetainerApi.GetOfflineCharacterData(c).Enabled);
#endregion

#region YesAlready
Expand Down
31 changes: 31 additions & 0 deletions SomethingNeedDoing/Misc/Commands/SystemCommands.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using FFXIVClientStructs.FFXIV.Client.System.Framework;
using FFXIVClientStructs.FFXIV.Client.UI;
using ImGuiNET;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;

namespace SomethingNeedDoing.Misc.Commands;

public class SystemCommands
{
internal static SystemCommands Instance { get; } = new();

public List<string> ListAllFunctions()
{
MethodInfo[] methods = this.GetType().GetMethods(BindingFlags.Public | BindingFlags.Instance | BindingFlags.FlattenHierarchy);
var list = new List<string>();
foreach (MethodInfo method in methods.Where(x => x.Name != nameof(ListAllFunctions) && x.DeclaringType != typeof(object)))
{
var parameterList = method.GetParameters().Select(p => $"{p.ParameterType.Name} {p.Name}{(p.IsOptional ? " = " + (p.DefaultValue ?? "null") : "")}");
list.Add($"{method.ReturnType.Name} {method.Name}({string.Join(", ", parameterList)})");
}
return list;
}

public string GetClipboard() => ImGui.GetClipboardText();

public void SetClipboard(string text) => ImGui.SetClipboardText(text);

public unsafe void CrashTheGame() => Framework.Instance()->UIModule = (UIModule*)0;
}

0 comments on commit cfbb74c

Please sign in to comment.