From c0a3356a4415279734e3ffb2602941200b50f6ed Mon Sep 17 00:00:00 2001 From: LIPtoH Date: Mon, 27 Nov 2023 16:22:17 +0500 Subject: [PATCH] System Tag&Write Info&Profile files only If Edited [update] --- .../CustomClasses/Save/SaveFileInfoData.cs | 2 + .../CustomClasses/Save/SaveFileProfileData.cs | 42 ++++++++++--------- .../Forms/MainTabs/FormMethodsCompanyTab.cs | 6 ++- TS SE Tool/MethodsReadWrite.cs | 18 ++++---- 4 files changed, 39 insertions(+), 29 deletions(-) diff --git a/TS SE Tool/CustomClasses/Save/SaveFileInfoData.cs b/TS SE Tool/CustomClasses/Save/SaveFileInfoData.cs index 6201d71..345f78b 100644 --- a/TS SE Tool/CustomClasses/Save/SaveFileInfoData.cs +++ b/TS SE Tool/CustomClasses/Save/SaveFileInfoData.cs @@ -51,6 +51,8 @@ class SaveFileInfoData : SiiNBlockCore internal List Dependencies { get; set; } = new List(); // + internal bool isEdited { get; set; } = false; + int unsortedOrder = 0; Dictionary> unsortedDataDict = new Dictionary>(); diff --git a/TS SE Tool/CustomClasses/Save/SaveFileProfileData.cs b/TS SE Tool/CustomClasses/Save/SaveFileProfileData.cs index 3f66c38..ad6cf24 100644 --- a/TS SE Tool/CustomClasses/Save/SaveFileProfileData.cs +++ b/TS SE Tool/CustomClasses/Save/SaveFileProfileData.cs @@ -33,11 +33,11 @@ class SaveFileProfileData : SiiNBlockCore internal string UserProfileNameless { get; set; } = ""; //--- - public bool GenederMale { get; set; } = false; + internal bool GenderMale { get; set; } = false; internal ushort Face { get; set; } = 0; internal string Brand { get; set; } = ""; - public string Logo { get; set; } = ""; + internal string Logo { get; set; } = ""; internal SCS_String CompanyName { get; set; } = ""; @@ -45,8 +45,8 @@ class SaveFileProfileData : SiiNBlockCore internal string MapPath { get; set; } = ""; //--- - public uint CachedExperiencePoints { get; set; } = 0; - public uint CachedDistance { get; set; } = 0; + internal uint CachedExperiencePoints { get; set; } = 0; + internal uint CachedDistance { get; set; } = 0; //--- #region UserData @@ -57,20 +57,20 @@ class SaveFileProfileData : SiiNBlockCore internal string ud1_WoTLicensePlate { get; set; } = ""; //1 WoT licenseplate internal string ud2_SomeCheckSum { get; set; } = ""; //2 ??? internal byte? ud3_WoTConnected { get; set; } = null; //3 isWoTConnected? - public decimal ud4_RoadsExplored { get; set; } = 0.0M; //4 Road explored persentage - public uint ud5_DeliveriesFinished { get; set; } = 0; //5 Finished deliveries - public uint ud6_OwnedTrucks { get; set; } = 0; //6 Owned trucks count - public uint ud7_OwnedGaradesSmall { get; set; } = 0; //7 Small garages - public uint ud8_OwnedGaradesLarge { get; set; } = 0; //8 Large garages - public ulong ud9_GameTimeSpent { get; set; } = 0; //9 Game time spent - public uint ud10_RealTimeSpent { get; set; } = 0; //10 Real time spent - public string ud11_CurrentTruck { get; set; } = ""; //11 Current truck //brand.model - - public List ud12_OwnedTruckList = new List(); //12 Owned trucks //brand.model:count,brand.model:count,...; + internal decimal ud4_RoadsExplored { get; set; } = 0.0M; //4 Road explored persentage + internal uint ud5_DeliveriesFinished { get; set; } = 0; //5 Finished deliveries + internal uint ud6_OwnedTrucks { get; set; } = 0; //6 Owned trucks count + internal uint ud7_OwnedGaradesSmall { get; set; } = 0; //7 Small garages + internal uint ud8_OwnedGaradesLarge { get; set; } = 0; //8 Large garages + internal ulong ud9_GameTimeSpent { get; set; } = 0; //9 Game time spent + internal uint ud10_RealTimeSpent { get; set; } = 0; //10 Real time spent + internal string ud11_CurrentTruck { get; set; } = ""; //11 Current truck //brand.model + + internal List ud12_OwnedTruckList = new List(); //12 Owned trucks //brand.model:count,brand.model:count,...; internal string ud13_SomeUserData { get; set; } = ""; //13 ??? internal uint? ud14_SomeUserData { get; set; } = null; //14 ??? //0 internal string ud15_SomeUserData { get; set; } = ""; //15 ??? //production - public uint ud16_OwnedTrailers { get; set; } = 0; //16 Owned trailers + internal uint ud16_OwnedTrailers { get; set; } = 0; //16 Owned trailers #region user data backend @@ -260,11 +260,13 @@ private string user_data_16 internal SCS_String ProfileName { get; set; } = ""; - public uint CreationTime { get; set; } = 0; - public uint SaveTime { get; set; } = 0; + internal uint CreationTime { get; set; } = 0; + internal uint SaveTime { get; set; } = 0; //==== - + + internal bool isEdited { get; set; } = false; + int unsortedOrder = 0; Dictionary> unsortedDataDict = new Dictionary>(); @@ -363,7 +365,7 @@ public void ProcessData(string[] _fileLines) case "male": { - GenederMale = bool.Parse(dataLine); + GenderMale = bool.Parse(dataLine); break; } @@ -521,7 +523,7 @@ public string PrintOut() sbResult.AppendLine(" map_path: " + MapPath); sbResult.AppendLine(" logo: " + Logo); sbResult.AppendLine(" company_name: " + CompanyName.ToString()); - sbResult.AppendLine(" male: " + GenederMale.ToString().ToLower()); + sbResult.AppendLine(" male: " + GenderMale.ToString().ToLower()); sbResult.AppendLine(" cached_experience: " + CachedExperiencePoints.ToString()); sbResult.AppendLine(" cached_distance: " + CachedDistance.ToString()); diff --git a/TS SE Tool/Forms/MainTabs/FormMethodsCompanyTab.cs b/TS SE Tool/Forms/MainTabs/FormMethodsCompanyTab.cs index e04a96b..caeda25 100644 --- a/TS SE Tool/Forms/MainTabs/FormMethodsCompanyTab.cs +++ b/TS SE Tool/Forms/MainTabs/FormMethodsCompanyTab.cs @@ -221,7 +221,11 @@ private void textBoxUserCompanyCompanyName_TextChanged(object sender, EventArgs labelCompanyNameSize.Text = textBoxUserCompanyCompanyName.Text.Length.ToString() + " / 20"; - MainSaveFileProfileData.CompanyName = new Save.DataFormat.SCS_String(textBoxUserCompanyCompanyName.Text); + if (textBoxUserCompanyCompanyName.Text != MainSaveFileProfileData.CompanyName.Value) + { + MainSaveFileProfileData.isEdited = true; + MainSaveFileProfileData.CompanyName = new Save.DataFormat.SCS_String(textBoxUserCompanyCompanyName.Text); + } } private void textBoxUserCompanyCompanyName_Validating(object sender, CancelEventArgs e) diff --git a/TS SE Tool/MethodsReadWrite.cs b/TS SE Tool/MethodsReadWrite.cs index a14a855..ce77251 100644 --- a/TS SE Tool/MethodsReadWrite.cs +++ b/TS SE Tool/MethodsReadWrite.cs @@ -996,16 +996,18 @@ private void NewWrireSaveFile(object sender, DoWorkEventArgs e) File.Copy(SiiSavePath, SiiSavePathBackup, true); //Write Profile data - using (StreamWriter writer = new StreamWriter(ProfileFolderPath, false)) - { - writer.Write(MainSaveFileProfileData.PrintOut()); - } + if (MainSaveFileProfileData.isEdited) + using (StreamWriter writer = new StreamWriter(ProfileFolderPath, false)) + { + writer.Write(MainSaveFileProfileData.PrintOut()); + } //Write Info data - using (StreamWriter writer = new StreamWriter(SiiInfoPath, false)) - { - writer.Write(MainSaveFileInfoData.PrintOut()); - } + if (MainSaveFileInfoData.isEdited) + using (StreamWriter writer = new StreamWriter(SiiInfoPath, false)) + { + writer.Write(MainSaveFileInfoData.PrintOut()); + } //Write Save data using (StreamWriter writer = new StreamWriter(SiiSavePath, false))