From fc1ff4854d62fbcb94fab291a510da69e40801f3 Mon Sep 17 00:00:00 2001 From: JappaWakka Date: Fri, 28 Apr 2023 09:17:10 +0200 Subject: [PATCH] Custom Phone Contacts are possible in GameModes --- .../Data/{Scripts/phone => }/contacts.dat | Bin P3D/P3D.vbproj | 2 +- P3D/Screens/Inventory/PokegearScreen.vb | 30 ++++++++++-------- 3 files changed, 18 insertions(+), 14 deletions(-) rename P3D/Content/Data/{Scripts/phone => }/contacts.dat (100%) diff --git a/P3D/Content/Data/Scripts/phone/contacts.dat b/P3D/Content/Data/contacts.dat similarity index 100% rename from P3D/Content/Data/Scripts/phone/contacts.dat rename to P3D/Content/Data/contacts.dat diff --git a/P3D/P3D.vbproj b/P3D/P3D.vbproj index 247475c95..875022ce4 100644 --- a/P3D/P3D.vbproj +++ b/P3D/P3D.vbproj @@ -5789,7 +5789,7 @@ PreserveNewest - + PreserveNewest diff --git a/P3D/Screens/Inventory/PokegearScreen.vb b/P3D/Screens/Inventory/PokegearScreen.vb index d3255a4ad..0a731c7bc 100644 --- a/P3D/Screens/Inventory/PokegearScreen.vb +++ b/P3D/Screens/Inventory/PokegearScreen.vb @@ -1369,7 +1369,7 @@ Dim reg() As String = Core.Player.RegisterData.Split(CChar(",")) - Dim contactData() As String = System.IO.File.ReadAllLines(GameController.GamePath & "\Content\Data\Scripts\phone\contacts.dat") + Dim contactData() As String = System.IO.File.ReadAllLines(GameModeManager.GetContentFilePath("Data\contacts.dat")) For Each r As String In reg If r.StartsWith("phone_contact_") = True Then @@ -1401,10 +1401,12 @@ Public Shared Sub CallID(ByVal ID As String, ByVal checkRegistered As Boolean, ByVal checkLocation As Boolean) Dim reg() As String = Core.Player.RegisterData.Split(CChar(",")) - Security.FileValidation.CheckFileValid(GameController.GamePath & "\Content\Data\Scripts\phone\contacts.dat", False, "PokegearScreen.vb") - Dim contactData() As String = System.IO.File.ReadAllLines(GameController.GamePath & "\Content\Data\Scripts\phone\contacts.dat") + Dim file As String = GameModeManager.GetContentFilePath("Data\contacts.dat") - Dim tempContacs As New List(Of Contact) + Security.FileValidation.CheckFileValid(file, False, "PokegearScreen.vb") + Dim contactData() As String = System.IO.File.ReadAllLines(file) + + Dim tempContacts As New List(Of Contact) For Each r As String In reg If r.StartsWith("phone_contact_") = True Then @@ -1417,7 +1419,7 @@ Dim newContact As New Contact With {.ID = NCD(0), .Name = NCD(1), .Texture = NCD(2), .Location = NCD(3), .CanRandomCall = CBool(NCD(4))} - tempContacs.Add(newContact) + tempContacts.Add(newContact) End If Next End If @@ -1425,7 +1427,7 @@ Next Dim countPossibleContacts As Integer = 0 - For Each c As Contact In tempContacs + For Each c As Contact In tempContacts If c.Location.ToLower() <> Level.MapName.ToLower() Or checkLocation = False Then countPossibleContacts += 1 End If @@ -1434,7 +1436,7 @@ If countPossibleContacts > 0 Then Dim chosenID As String = "-1" While chosenID = "-1" - Dim nC As Contact = tempContacs(Core.Random.Next(0, tempContacs.Count)) + Dim nC As Contact = tempContacts(Core.Random.Next(0, tempContacts.Count)) If nC.Location.ToLower() <> Level.MapName.ToLower() Or checkLocation = False Then chosenID = nC.ID @@ -1454,10 +1456,12 @@ Dim reg() As String = Core.Player.RegisterData.Split(CChar(",")) - Security.FileValidation.CheckFileValid(GameController.GamePath & "\Content\Data\Scripts\phone\contacts.dat", False, "PokegearScreen.vb") - Dim contactData() As String = System.IO.File.ReadAllLines(GameController.GamePath & "\Content\Data\Scripts\phone\contacts.dat") + Dim file As String = GameModeManager.GetContentFilePath("Data\contacts.dat") - Dim tempContacs As New List(Of Contact) + Security.FileValidation.CheckFileValid(file, False, "PokegearScreen.vb") + Dim contactData() As String = System.IO.File.ReadAllLines(file) + + Dim tempContacts As New List(Of Contact) For Each r As String In reg If r.StartsWith("phone_contact_") = True Then @@ -1469,14 +1473,14 @@ Dim newContact As New Contact With {.ID = NCD(0), .Name = NCD(1), .Texture = NCD(2), .Location = NCD(3), .CanRandomCall = CBool(NCD(4))} - tempContacs.Add(newContact) + tempContacts.Add(newContact) End If Next End If Next Dim countPossibleContacts As Integer = 0 - For Each c As Contact In tempContacs + For Each c As Contact In tempContacts If c.CanRandomCall = True And c.Location.ToLower() <> Level.MapName.ToLower() Then countPossibleContacts += 1 End If @@ -1485,7 +1489,7 @@ If countPossibleContacts > 0 Then Dim chosenID As String = "-1" While chosenID = "-1" - Dim nC As Contact = tempContacs(Core.Random.Next(0, tempContacs.Count)) + Dim nC As Contact = tempContacts(Core.Random.Next(0, tempContacts.Count)) If nC.CanRandomCall = True And nC.Location.ToLower() <> Level.MapName.ToLower() Then chosenID = nC.ID