Skip to content

Commit

Permalink
Few changes to host UI + removed STUN dependency
Browse files Browse the repository at this point in the history
- Changes to the UI to have the "Relay" button in first position (since it's the default option).
- Changed if statements to reflect the new index of Peer to Peer selection.
- Added a warning for P2P mode.
- Added dictionary entries for Port and the P2P warning.
- Removed STUN.dll dependency because the STUN library is now part of the source code and no longer a NuGet Package, so this is no longer needed.
  • Loading branch information
trippyone committed Feb 17, 2024
1 parent 15ccce1 commit 4b9f724
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 24 deletions.
25 changes: 17 additions & 8 deletions Source/Coop/Components/SITMatchmakerGUIComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ internal class SITMatchmakerGUIComponent : MonoBehaviour

private int botAmountInput = 0;
private int botDifficultyInput = 0;
private int protocolInput = 1;
private int protocolInput = 0;
private string pendingServerId = "";
private int p2pAddressOptionInput;
private string IpAddressInput { get; set; } = SITIPAddressManager.SITIPAddresses.ExternalAddresses.IPAddressV4;
Expand Down Expand Up @@ -567,7 +567,7 @@ void JoinMatch(string profileId, string serverId, string password = "")

void DrawHostGameWindow(int windowID)
{
var rows = 9;
var rows = 10;
var halfWindowWidth = windowInnerRect.width / 2;

var cols = new float[] { halfWindowWidth * 0.1f, halfWindowWidth * 0.66f, halfWindowWidth * 1.01f, halfWindowWidth * 1.33f };
Expand Down Expand Up @@ -694,7 +694,7 @@ void DrawHostGameWindow(int windowID)
case 6:

// If Peer to Peer is chosen
if (protocolInput == 0)
if (protocolInput == 1)
{
// P2P Address Option Choice
GUI.Label(new Rect(cols[0], y, labelStyle.CalcSize(new GUIContent(StayInTarkovPlugin.LanguageDictionary["P2P_IP_ADDRESS_OPTIONS_LABEL"].ToString())).x, calcSizeContentLabelNumberOfPlayers.y), StayInTarkovPlugin.LanguageDictionary["P2P_IP_ADDRESS_OPTIONS_LABEL"].ToString(), labelStyle);
Expand All @@ -705,33 +705,42 @@ void DrawHostGameWindow(int windowID)
break;
case 7:
// If Peer to Peer is chosen and manually set
if (protocolInput == 0 && p2pAddressOptionInput == 1)
if (protocolInput == 1 && p2pAddressOptionInput == 1)
{
// P2P Address Option Choice
GUI.Label(new Rect(cols[0], y, labelStyle.CalcSize(new GUIContent(StayInTarkovPlugin.LanguageDictionary["P2P_IP_ADDRESS_LABEL"].ToString())).x, calcSizeContentLabelNumberOfPlayers.y), StayInTarkovPlugin.LanguageDictionary["P2P_IP_ADDRESS_LABEL"].ToString(), labelStyle);

Rect p2pAddressIPRect = new Rect(cols[1], y, 200, 25);
IpAddressInput = GUI.TextField(p2pAddressIPRect, IpAddressInput, 16);
}
if (protocolInput == 0 && p2pAddressOptionInput == 0)
if (protocolInput == 1 && p2pAddressOptionInput == 0)
{
// Port Number Choice
GUI.Label(new Rect(cols[0], y, labelStyle.CalcSize(new GUIContent("Port")).x, calcSizeContentLabelNumberOfPlayers.y), "Port", labelStyle);
GUI.Label(new Rect(cols[0], y, labelStyle.CalcSize(new GUIContent(StayInTarkovPlugin.LanguageDictionary["P2P_PORT_LABEL"].ToString())).x, calcSizeContentLabelNumberOfPlayers.y), StayInTarkovPlugin.LanguageDictionary["P2P_PORT_LABEL"].ToString(), labelStyle);

Rect p2pPortRect = new Rect(cols[1], y, 100, 25);
PortInput = int.Parse(GUI.TextField(p2pPortRect, PortInput.ToString(), 16));
}
break;
case 8:
if (protocolInput == 0 && p2pAddressOptionInput == 1)
if (protocolInput == 1 && p2pAddressOptionInput == 1)
{
// Port Number Choice
GUI.Label(new Rect(cols[0], y, labelStyle.CalcSize(new GUIContent("Port")).x, calcSizeContentLabelNumberOfPlayers.y), "Port", labelStyle);
GUI.Label(new Rect(cols[0], y, labelStyle.CalcSize(new GUIContent(StayInTarkovPlugin.LanguageDictionary["P2P_PORT_LABEL"].ToString())).x, calcSizeContentLabelNumberOfPlayers.y), StayInTarkovPlugin.LanguageDictionary["P2P_PORT_LABEL"].ToString(), labelStyle);

Rect p2pPortRect = new Rect(cols[1], y, 100, 25);
PortInput = int.Parse(GUI.TextField(p2pPortRect, PortInput.ToString(), 16));
}
break;
case 9:
if(protocolInput == 1)
{
var warningLabelStyle = new GUIStyle(GUI.skin.label);
warningLabelStyle.fontStyle = FontStyle.Bold;

GUI.Label(new Rect(cols[1], y, labelStyle.CalcSize(new GUIContent(StayInTarkovPlugin.LanguageDictionary["P2P_WARNING_LABEL"].ToString())).x, calcSizeContentLabelNumberOfPlayers.y), StayInTarkovPlugin.LanguageDictionary["P2P_WARNING_LABEL"].ToString(), warningLabelStyle);
}
break;
}
}

Expand Down
8 changes: 4 additions & 4 deletions Source/Networking/ESITProtocol.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ namespace StayInTarkov.Networking
public enum ESITProtocol : int
{
/// <summary>
/// Peer to Peer connections over UDP
/// Relay TCP between SIT Client -> Web Server -> SIT Client
/// </summary>
PeerToPeerUdp = 0,
RelayTcp = 0,

/// <summary>
/// Relay TCP between SIT Client -> Web Server -> SIT Client
/// Peer to Peer connections over UDP
/// </summary>
RelayTcp = 1,
PeerToPeerUdp = 1,

/// <summary>
/// Currently unused
Expand Down
6 changes: 4 additions & 2 deletions Source/Resources/Language/English.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@
"RAID_PLAYER_EXTRACTED_HOST": "You have extracted! Please wait other player(s) to extract or died.",
"RAID_PLAYER_EXTRACTED_CLIENT": "You have extracted! Please wait for all players to extract or quit now using the F8 Key.",
"PROTOCOL": "Protocol",
"PROTOCOL_OPTIONS": [ "Peer to Peer", "Relay" ],
"PROTOCOL_OPTIONS": [ "Relay", "Peer to Peer" ],
"P2P_IP_ADDRESS_OPTIONS_LABEL": "Auto select IP Address?",
"YES_NO_OPTIONS": [ "Yes", "No" ],
"P2P_IP_ADDRESS_LABEL": "IP Address"
"P2P_IP_ADDRESS_LABEL": "IP Address",
"P2P_PORT_LABEL": "Port",
"P2P_WARNING_LABEL": "Warning: P2P is an experimental feature. You may experience additional issues in this mode."
}
Binary file removed Source/STUN.dll
Binary file not shown.
11 changes: 1 addition & 10 deletions Source/StayInTarkov.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,6 @@
<None Remove="Networking\Packets\**" />
</ItemGroup>

<ItemGroup>
<None Remove="STUN.dll" />
</ItemGroup>

<ItemGroup>
<Content Include="STUN.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>

<ItemGroup>
<EmbeddedResource Include="Resources\Language\English.json">
</EmbeddedResource>
Expand Down Expand Up @@ -155,6 +145,7 @@

<ItemGroup>
<Folder Include="Networking\Nat\" />
<Folder Include="Properties\" />
</ItemGroup>

</Project>

0 comments on commit 4b9f724

Please sign in to comment.