Skip to content

Commit

Permalink
Add login / shutdown
Browse files Browse the repository at this point in the history
  • Loading branch information
GiR_Zippo committed Jul 15, 2024
1 parent e84df8a commit f2c3597
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 1 deletion.
27 changes: 27 additions & 0 deletions HypnotoadPlugin/GameFunctions/MiscGameFunctions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using HypnotoadPlugin.Offsets;
using System.Threading.Tasks;
using System.Threading;
using System;

namespace HypnotoadPlugin.GameFunctions;

public static class MiscGameFunctions
{
public static void CharacterLogout()
{
Party.Instance.AcceptPartyInviteEnable();
Api.Framework.RunOnTick(delegate
{
Chat.SendMessage("/logout");
}, default(TimeSpan), 10, default(CancellationToken));
}

public static void GameShutdown()
{
Party.Instance.AcceptPartyInviteEnable();
Api.Framework.RunOnTick(delegate
{
Chat.SendMessage("/shutdown");
}, default(TimeSpan), 10, default(CancellationToken));
}
}
2 changes: 1 addition & 1 deletion HypnotoadPlugin/HypnotoadPlugin.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

<Description>BardMusicPlayer &amp; LightAmp companion for enhanced functionality.</Description>
<PackageProjectUrl>https://github.com/GiR-Zippo/Hypnotoad-Plugin</PackageProjectUrl>
<Version>0.0.1.33</Version>
<Version>0.0.1.34</Version>
</PropertyGroup>

<PropertyGroup>
Expand Down
2 changes: 2 additions & 0 deletions HypnotoadPlugin/IPC/IPCProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ public IPCProvider(Hypnotoad toad)
Register("PartyUnFollow", () => FollowSystem.StopFollow());
Register("MoveTo", (string data) => MovementFactory.Instance.MoveTo(data));
Register("MoveStop", () => MovementFactory.Instance.StopMovement());
Register("CharacterLogout", () => MiscGameFunctions.CharacterLogout());
Register("GameShutdown", () => MiscGameFunctions.GameShutdown());
}

public void Dispose() => _disposeActions?.Invoke();
Expand Down
6 changes: 6 additions & 0 deletions HypnotoadPlugin/MessageEnums.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ public enum MessageType
None = 0,
Handshake = 1,
Version = 2,
MoveCharToPosition = 3,
StopMovement = 4,

ClientLogout = 5,
GameShutdown = 6,

SetGfx = 10, //Get<->Set
NameAndHomeWorld = 11, //Get
Expand Down Expand Up @@ -43,6 +48,7 @@ public enum MessageType
PartyEnterHouse = 63,
PartyTeleport = 64, //Set (host?show menu : accept TP)
PartyFollow = 65 //Set (name";"HomeWorldId) | "" unfollow

}

public readonly struct ChatMessageChannelType
Expand Down
12 changes: 12 additions & 0 deletions HypnotoadPlugin/Utils/AutoSelect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,18 @@ protected unsafe void AddonSetup(AddonEvent eventType, AddonArgs addonInfo)
Party.Instance.AcceptDisable();
return;
}
else if (Langstrings.ConfirmLogout.Any(r => r.IsMatch(text)))
{
SelectYes(addon);
Party.Instance.AcceptDisable();
return;
}
else if (Langstrings.ConfirmShutdown.Any(r => r.IsMatch(text)))
{
SelectYes(addon);
Party.Instance.AcceptDisable();
return;
}
}

public static unsafe bool SelectYes(AtkUnitBase* addon)
Expand Down
12 changes: 12 additions & 0 deletions HypnotoadPlugin/Utils/Langstrings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,16 @@ public static class Langstrings
new Regex(@"Voulez-vous vous téléporter vers la destination .* \?")

];

internal static readonly List<Regex> ConfirmLogout =
[
new Regex(@"Zum Titelbildschirm zurückkehren\?"),
new Regex(@"Se déconnecter et retourner à l'écram titre \?")
];

internal static readonly List<Regex> ConfirmShutdown =
[
new Regex(@"Das Spiel beenden\?"),
new Regex(@"Se déconnecter et quitter le jeu \?")
];
}
8 changes: 8 additions & 0 deletions HypnotoadPlugin/Windows/MainWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@ private void pipeClient_MessageReceived(object sender, ConnectionMessageEventArg
case MessageType.ProgramChange:
PerformActions.GuitarSwitchTone(Convert.ToInt32(inMsg.message));
break;
case MessageType.ClientLogout:
case MessageType.GameShutdown:
case MessageType.Chat:
case MessageType.Instrument:
case MessageType.AcceptReply:
Expand Down Expand Up @@ -175,6 +177,12 @@ public override void Update()
var msg = qt.Dequeue();
switch (msg.msgType)
{
case MessageType.ClientLogout:
MiscGameFunctions.CharacterLogout();
break;
case MessageType.GameShutdown:
MiscGameFunctions.GameShutdown();
break;
case MessageType.Chat:
var chatMessageChannelType = ChatMessageChannelType.ParseByChannelCode(msg.msgChannel);
if (chatMessageChannelType.Equals(ChatMessageChannelType.None))
Expand Down

0 comments on commit f2c3597

Please sign in to comment.