Fixed messages

This commit is contained in:
Garrett
2023-08-24 23:12:04 -05:00
parent 5397b4e04e
commit 91f0e57d97
4 changed files with 35 additions and 27 deletions

View File

@@ -17,6 +17,7 @@ using VRage.Game;
using Sandbox.Engine.Networking; using Sandbox.Engine.Networking;
using VRage; using VRage;
using VRage.GameServices; using VRage.GameServices;
using VRageRender;
namespace SeamlessClient.Components namespace SeamlessClient.Components
{ {
@@ -36,8 +37,8 @@ namespace SeamlessClient.Components
patcher.Patch(loadingAction, prefix: new HarmonyMethod(Get(typeof(LoadingScreenComponent), nameof(LoadMultiplayerSession)))); patcher.Patch(loadingAction, prefix: new HarmonyMethod(Get(typeof(LoadingScreenComponent), nameof(LoadMultiplayerSession))));
patcher.Patch(loadingScreenDraw, prefix: new HarmonyMethod(Get(typeof(LoadingScreenComponent), nameof(DrawInternal)))); patcher.Patch(loadingScreenDraw, prefix: new HarmonyMethod(Get(typeof(LoadingScreenComponent), nameof(DrawInternal_PRE))));
patcher.Patch(loadingScreenDraw, postfix: new HarmonyMethod(Get(typeof(LoadingScreenComponent), nameof(DrawInternal_POST))));
base.Patch(patcher); base.Patch(patcher);
@@ -112,16 +113,11 @@ namespace SeamlessClient.Components
} }
private static bool DrawInternal(MyGuiScreenLoading __instance) private static bool DrawInternal_PRE(MyGuiScreenLoading __instance)
{ {
//If we dont have a custom loading screen texture, do not do the special crap below //If we dont have a custom loading screen texture, do not do the special crap below
const string mFont = "LoadingScreen";
var mTransitionAlpha = (float)typeof(MyGuiScreenBase).GetField("m_transitionAlpha", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(__instance);
MyGuiManager.DrawString(mFont, "Nexus & SeamlessClient Made by: Casimir", new Vector2(0.95f, 0.95f),
MyGuiSandbox.GetDefaultTextScaleWithLanguage() * 1.1f,
new Color(MyGuiConstants.LOADING_PLEASE_WAIT_COLOR * mTransitionAlpha),
MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_BOTTOM);
@@ -129,7 +125,8 @@ namespace SeamlessClient.Components
return true; return true;
const string mFont = "LoadingScreen";
var mTransitionAlpha = (float)typeof(MyGuiScreenBase).GetField("m_transitionAlpha", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(__instance);
var color = new Color(255, 255, 255, 250); var color = new Color(255, 255, 255, 250);
color.A = (byte)(color.A * mTransitionAlpha); color.A = (byte)(color.A * mTransitionAlpha);
@@ -155,6 +152,12 @@ namespace SeamlessClient.Components
/* /*
if (string.IsNullOrEmpty(m_customTextFromConstructor)) if (string.IsNullOrEmpty(m_customTextFromConstructor))
{ {
@@ -172,6 +175,14 @@ namespace SeamlessClient.Components
return false; return false;
} }
private static void DrawInternal_POST(MyGuiScreenLoading __instance)
{
const string mFont = "LoadingScreen";
var mTransitionAlpha = (float)typeof(MyGuiScreenBase).GetField("m_transitionAlpha", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(__instance);
MyGuiManager.DrawString(mFont, "Nexus & SeamlessClient Made by: Casimir", new Vector2(0.95f, 0.95f),
MyGuiSandbox.GetDefaultTextScaleWithLanguage() * 1.1f,
new Color(MyGuiConstants.LOADING_PLEASE_WAIT_COLOR * mTransitionAlpha),
MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_BOTTOM);
}
} }
} }

View File

@@ -25,7 +25,7 @@ namespace SeamlessClient.Messages
[ProtoMember(3)] public long IdentityID; [ProtoMember(3)] public long IdentityID;
[ProtoMember(4)] public ulong SteamID; [ProtoMember(4)] public ulong SteamID;
[ProtoMember(5)] public string PluginVersion = "0"; [ProtoMember(5)] public string PluginVersion = "0";
[ProtoMember(6)] public string NexusVersion = "0"; [ProtoMember(6)] public string NexusVersion;
public ClientMessage(string PluginVersion) public ClientMessage(string PluginVersion)
{ {
@@ -37,6 +37,8 @@ namespace SeamlessClient.Messages
} }
public ClientMessage() { }
public TransferData GetTransferData() public TransferData GetTransferData()
{ {
return MessageData == null ? default : MessageUtils.Deserialize<TransferData>(MessageData); return MessageData == null ? default : MessageUtils.Deserialize<TransferData>(MessageData);

View File

@@ -853,7 +853,6 @@ namespace SeamlessClient.OnlinePlayersWindow
{ {
bool result = base.Draw(); bool result = base.Draw();
Seamless.TryShow("Draw!");
if (m_getPingAndRefresh) if (m_getPingAndRefresh)
{ {
m_getPingAndRefresh = false; m_getPingAndRefresh = false;

View File

@@ -24,7 +24,7 @@ namespace SeamlessClient
public class Seamless : IPlugin public class Seamless : IPlugin
{ {
public static Version SeamlessVersion; public static Version SeamlessVersion;
public static Version NexusVersion; public static Version NexusVersion = new Version(1, 0, 0);
private static Harmony SeamlessPatcher; private static Harmony SeamlessPatcher;
public const ushort SeamlessClientNetId = 2936; public const ushort SeamlessClientNetId = 2936;
@@ -33,14 +33,8 @@ namespace SeamlessClient
private bool Initilized = false; private bool Initilized = false;
public static bool isSeamlessServer = false; public static bool isSeamlessServer = false;
#if DEBUG
public static bool isDebug = true; public static bool isDebug = true;
#else
public static bool isDebug = false;
#endif
public void Init(object gameInstance) public void Init(object gameInstance)
@@ -118,24 +112,26 @@ namespace SeamlessClient
private static void MessageHandler(ushort packetID, byte[] data, ulong sender, bool fromServer) private static void MessageHandler(ushort packetID, byte[] data, ulong sender, bool fromServer)
{ {
//Ignore anything except dedicated server //Ignore anything except dedicated server
if (!fromServer || sender != 0)
Seamless.TryShow($"From Server {fromServer} - {sender}");
if (!fromServer || sender == 0)
return; return;
if (MyAPIGateway.Multiplayer == null || MyAPIGateway.Multiplayer.IsServer) return;
if (MyAPIGateway.Session.LocalHumanPlayer == null) return;
ClientMessage msg = MessageUtils.Deserialize<ClientMessage>(data); ClientMessage msg = MessageUtils.Deserialize<ClientMessage>(data);
if (msg == null) if (msg == null)
return; return;
//Get Nexus Version //Get Nexus Version
Seamless.TryShow($"NexusVersion {msg.NexusVersion}");
if (!string.IsNullOrEmpty(msg.NexusVersion))
NexusVersion = Version.Parse(msg.NexusVersion); NexusVersion = Version.Parse(msg.NexusVersion);
switch (msg.MessageType) switch (msg.MessageType)
{ {
case ClientMessageType.FirstJoin: case ClientMessageType.FirstJoin:
Seamless.TryShow("Sending First Join!");
ClientMessage response = new ClientMessage(SeamlessVersion.ToString()); ClientMessage response = new ClientMessage(SeamlessVersion.ToString());
MyAPIGateway.Multiplayer?.SendMessageToServer(SeamlessClientNetId, MessageUtils.Serialize(response)); MyAPIGateway.Multiplayer?.SendMessageToServer(SeamlessClientNetId, MessageUtils.Serialize(response));
break; break;