Skip to content

Commit

Permalink
Merge pull request #386 from Micdu70/patch-1
Browse files Browse the repository at this point in the history
Close #385
  • Loading branch information
qubqub authored Oct 11, 2024
2 parents 495ab93 + 23edba9 commit fc7c49f
Show file tree
Hide file tree
Showing 4 changed files with 99 additions and 36 deletions.
1 change: 1 addition & 0 deletions Entities/Profiles.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ public class Profiles {
public string ProfileName { get; set; }
public int ProfileOrder { get; set; }
public string LinkedShowId { get; set; }
public bool DoNotCombineShows { get; set; }
}
}
4 changes: 2 additions & 2 deletions FallGuysStats.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -1162,7 +1162,7 @@
<PackageReference Include="System.Diagnostics.DiagnosticSource" Version="8.0.1" />
<PackageReference Include="System.Diagnostics.Tools" Version="4.3.0" />
<PackageReference Include="System.Diagnostics.Tracing" Version="4.3.0" />
<PackageReference Include="System.Drawing.Common" Version="8.0.8" />
<PackageReference Include="System.Drawing.Common" Version="8.0.10" />
<PackageReference Include="System.Drawing.Primitives" Version="4.3.0" />
<PackageReference Include="System.Globalization" Version="4.3.0" />
<PackageReference Include="System.Globalization.Calendars" Version="4.3.0" />
Expand Down Expand Up @@ -1197,7 +1197,7 @@
<PackageReference Include="System.Text.Encoding" Version="4.3.0" />
<PackageReference Include="System.Text.Encoding.Extensions" Version="4.3.0" />
<PackageReference Include="System.Text.Encodings.Web" Version="8.0.0" />
<PackageReference Include="System.Text.Json" Version="8.0.4" />
<PackageReference Include="System.Text.Json" Version="8.0.5" />
<PackageReference Include="System.Text.RegularExpressions" Version="4.3.1" />
<PackageReference Include="System.Threading" Version="4.3.0" />
<PackageReference Include="System.Threading.Tasks" Version="4.3.0" />
Expand Down
20 changes: 13 additions & 7 deletions Views/EditProfiles.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,21 +108,25 @@ private void SetTheme(MetroThemeStyle theme) {
this.Theme = theme;
this.ResumeLayout();
}

private void InitProfileList() {
this.cboShowsList = new DataGridViewComboBoxColumn {
DisplayStyle = DataGridViewComboBoxDisplayStyle.ComboBox
};
DataTable showsData = new DataTable();
showsData.Columns.Add("showName");
showsData.Columns.Add("showId");
showsData.Rows.Add("", "");
showsData.Columns.Add("doNotCombineShows");
showsData.Rows.Add("", "", "False");
foreach (string showId in this.StatsForm.PublicShowIdList) {
showsData.Rows.Add(Multilingual.GetShowName(showId), showId);
showsData.Rows.Add(Multilingual.GetShowName(showId), showId, "False");
}

foreach (string showId in this.StatsForm.PublicShowIdList2) {
showsData.Rows.Add(Multilingual.GetShowName(showId), showId, "True");
}

showsData.DefaultView.Sort = "showName ASC";

this.cboShowsList.DataSource = showsData;
this.cboShowsList.DisplayMember = "showName";
this.cboShowsList.ValueMember = "showId";
Expand Down Expand Up @@ -192,13 +196,15 @@ private void ProfileList_EditingControlShowing(object sender, DataGridViewEditin
private void SubCombo_SelectionChangeCommitted(object sender, EventArgs e) {
DataRowView dataRow = (DataRowView)((ComboBox)sender).SelectedItem;
string linkedShowId = (string)dataRow.Row[1];

bool doNotCombineShows = bool.Parse((string)dataRow.Row[2]);

if (this.Profiles.FindIndex(item => item.LinkedShowId == linkedShowId) != -1) {
((ComboBox)sender).SelectedIndex = this.selectedRowIndex;
} else {
int profileListIndex = this.dgvProfiles.CurrentCell.RowIndex;
int profileIndex = this.Profiles.Count - profileListIndex - 1;
this.Profiles[profileIndex].LinkedShowId = linkedShowId;
this.Profiles[profileIndex].DoNotCombineShows = doNotCombineShows;
this.IsUpdate = true;
this.selectedRowIndex = ((ComboBox)sender).SelectedIndex;
}
Expand Down Expand Up @@ -239,7 +245,7 @@ private void AddPageButton_Click(object sender, EventArgs e) {
Multilingual.GetWord("message_create_profile_caption"), MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK) {
int maxId = this.Profiles.Max(p => p.ProfileId);
int maxOrder = this.Profiles.Max(p => p.ProfileOrder);
this.Profiles.Insert(0, new Profiles { ProfileId = maxId + 1, ProfileName = string.IsNullOrEmpty(this.txtAddProfile.Text) ? Utils.ComputeHash(BitConverter.GetBytes(DateTime.Now.Ticks), HashTypes.MD5).Substring(0, 20) : this.txtAddProfile.Text, ProfileOrder = maxOrder + 1, LinkedShowId = string.Empty });
this.Profiles.Insert(0, new Profiles { ProfileId = maxId + 1, ProfileName = string.IsNullOrEmpty(this.txtAddProfile.Text) ? Utils.ComputeHash(BitConverter.GetBytes(DateTime.Now.Ticks), HashTypes.MD5).Substring(0, 20) : this.txtAddProfile.Text, ProfileOrder = maxOrder + 1, LinkedShowId = string.Empty, DoNotCombineShows = false });
this.IsUpdate = true;
this.ReloadProfileList();
this.dgvProfiles[0, this.dgvProfiles.RowCount - 1].Selected = true;
Expand Down
110 changes: 83 additions & 27 deletions Views/Stats.cs
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,18 @@ private static bool IsAlreadyRunning() {
"private_lobbies"
};

public readonly string[] PublicShowIdList2 = {
"knockout_mode",
"no_elimination_explore",
// "knockout_duos",
"teams_show_ltm",
"event_day_at_races_squads_template",
// "knockout_squads",
"squadcelebration",
"invisibeans_pistachio_template",
"xtreme_explore"
};

public string GetUserCreativeLevelTypeId(string gameModeId) {
switch (gameModeId) {
case "GAMEMODE_GAUNTLET": return "user_creative_race_round";
Expand Down Expand Up @@ -614,16 +626,16 @@ private Stats() {
this.StatsDB.BeginTrans();
for (int i = this.PublicShowIdList.Length; i >= 1; i--) {
string showId = this.PublicShowIdList[i - 1];
this.Profiles.Insert(new Profiles { ProfileId = i - 1, ProfileName = Multilingual.GetShowName(showId), ProfileOrder = i, LinkedShowId = showId });
this.Profiles.Insert(new Profiles { ProfileId = i - 1, ProfileName = Multilingual.GetShowName(showId), ProfileOrder = i, LinkedShowId = showId, DoNotCombineShows = false });
}
this.StatsDB.Commit();
this.CurrentSettings.AutoChangeProfile = true;
} else {
this.StatsDB.BeginTrans();
this.Profiles.Insert(new Profiles { ProfileId = 3, ProfileName = Multilingual.GetWord("main_profile_custom"), ProfileOrder = 4, LinkedShowId = "private_lobbies" });
this.Profiles.Insert(new Profiles { ProfileId = 2, ProfileName = Multilingual.GetWord("main_profile_squad"), ProfileOrder = 3, LinkedShowId = "squads_4player" });
this.Profiles.Insert(new Profiles { ProfileId = 1, ProfileName = Multilingual.GetWord("main_profile_duo"), ProfileOrder = 2, LinkedShowId = "squads_2player_template" });
this.Profiles.Insert(new Profiles { ProfileId = 0, ProfileName = Multilingual.GetWord("main_profile_solo"), ProfileOrder = 1, LinkedShowId = "main_show" });
this.Profiles.Insert(new Profiles { ProfileId = 3, ProfileName = Multilingual.GetWord("main_profile_custom"), ProfileOrder = 4, LinkedShowId = "private_lobbies", DoNotCombineShows = false });
this.Profiles.Insert(new Profiles { ProfileId = 2, ProfileName = Multilingual.GetWord("main_profile_squad"), ProfileOrder = 3, LinkedShowId = "squads_4player", DoNotCombineShows = false });
this.Profiles.Insert(new Profiles { ProfileId = 1, ProfileName = Multilingual.GetWord("main_profile_duo"), ProfileOrder = 2, LinkedShowId = "squads_2player_template", DoNotCombineShows = false });
this.Profiles.Insert(new Profiles { ProfileId = 0, ProfileName = Multilingual.GetWord("main_profile_solo"), ProfileOrder = 1, LinkedShowId = "main_show", DoNotCombineShows = false });
this.StatsDB.Commit();
}
}
Expand Down Expand Up @@ -4844,40 +4856,69 @@ private bool IsCreativeShow(string showId) {
|| (showId.StartsWith("event_") && showId.EndsWith("_fools"));
}

private int GetLinkedProfileId(string showId, bool isPrivateLobbies) {
if (this.AllProfiles.Count == 0 || string.IsNullOrEmpty(showId)) return 0;
showId = this.GetAlternateShowId(showId);
foreach (Profiles profiles in this.AllProfiles) {
if (isPrivateLobbies) {
if (!string.IsNullOrEmpty(profiles.LinkedShowId) && string.Equals(profiles.LinkedShowId, "private_lobbies")) {
private int GetLinkedProfileId(string realShowId, bool isPrivateLobbies) {
if (this.AllProfiles.Count == 0 || string.IsNullOrEmpty(realShowId)) return 0;
string showId = this.GetAlternateShowId(realShowId);
foreach (Profiles profiles in this.AllProfiles.OrderBy(p => p.DoNotCombineShows ? 0 : 1)) {
if (profiles.DoNotCombineShows) {
if (!isPrivateLobbies && !string.IsNullOrEmpty(profiles.LinkedShowId) && realShowId.IndexOf(profiles.LinkedShowId, StringComparison.OrdinalIgnoreCase) != -1) {
return profiles.ProfileId;
}
} else {
if (this.IsCreativeShow(showId)) {
if (!string.IsNullOrEmpty(profiles.LinkedShowId) && string.Equals(profiles.LinkedShowId, "fall_guys_creative_mode")) {
if (isPrivateLobbies) {
if (!string.IsNullOrEmpty(profiles.LinkedShowId) && string.Equals(profiles.LinkedShowId, "private_lobbies")) {
return profiles.ProfileId;
}
} else {
if (!string.IsNullOrEmpty(profiles.LinkedShowId) && showId.IndexOf(profiles.LinkedShowId, StringComparison.OrdinalIgnoreCase) != -1) {
return profiles.ProfileId;
if (this.IsCreativeShow(showId)) {
if (!string.IsNullOrEmpty(profiles.LinkedShowId) && string.Equals(profiles.LinkedShowId, "fall_guys_creative_mode")) {
return profiles.ProfileId;
}
} else {
if (!string.IsNullOrEmpty(profiles.LinkedShowId) && showId.IndexOf(profiles.LinkedShowId, StringComparison.OrdinalIgnoreCase) != -1) {
return profiles.ProfileId;
}
}
}
}
}
if (isPrivateLobbies) {
// return corresponding linked profile when possible if no linked "private_lobbies" profile was found
return (from profiles in this.AllProfiles where !string.IsNullOrEmpty(profiles.LinkedShowId) && showId.IndexOf(profiles.LinkedShowId, StringComparison.OrdinalIgnoreCase) != -1 select profiles.ProfileId).FirstOrDefault();
return (from profiles in this.AllProfiles.OrderBy(p => p.DoNotCombineShows ? 0 : 1) where !string.IsNullOrEmpty(profiles.LinkedShowId) && showId.IndexOf(profiles.LinkedShowId, StringComparison.OrdinalIgnoreCase) != -1 select profiles.ProfileId).FirstOrDefault();
}
// return ProfileId 0 if no linked profile was found/matched
return 0;
}

public void SetLinkedProfileMenu(string showId, bool isPrivateLobbies) {
if (this.AllProfiles.Count == 0 || string.IsNullOrEmpty(showId)) return;
showId = this.GetAlternateShowId(showId);
if (string.Equals(this.GetCurrentProfileLinkedShowId(), showId)) return;
public void SetLinkedProfileMenu(string realShowId, bool isPrivateLobbies) {
if (this.AllProfiles.Count == 0 || string.IsNullOrEmpty(realShowId)) return;
string currentProfileLinkedShowId = this.GetCurrentProfileLinkedShowId();
bool isCurrentProfileIsDNCS = this.AllProfiles.Find(p => p.ProfileId == this.GetCurrentProfileId()).DoNotCombineShows;
if (isCurrentProfileIsDNCS && string.Equals(currentProfileLinkedShowId, realShowId)) return;
string showId = this.GetAlternateShowId(realShowId);
int linkedDNCSProfileId = this.AllProfiles.Find(p => p.DoNotCombineShows && string.Equals(p.LinkedShowId, realShowId))?.ProfileId ?? -1;
if (linkedDNCSProfileId == -1 && string.Equals(currentProfileLinkedShowId, showId)) return;
this.BeginInvoke((MethodInvoker)delegate {
int profileId = -1;
bool isLinkedProfileFound = false;
foreach (Profiles profiles in this.AllProfiles.FindAll(p => p.DoNotCombineShows)) {
if (!isPrivateLobbies && !string.IsNullOrEmpty(profiles.LinkedShowId) && realShowId.IndexOf(profiles.LinkedShowId, StringComparison.OrdinalIgnoreCase) != -1) {
profileId = profiles.ProfileId;
isLinkedProfileFound = true;
break;
}
}
for (int i = 0; i < this.AllProfiles.Count; i++) {
if (isLinkedProfileFound) {
if (this.AllProfiles[i].ProfileId == profileId) {
ToolStripMenuItem item = this.ProfileMenuItems[this.AllProfiles.Count - 1 - i];
if (!item.Checked) { this.menuStats_Click(item, EventArgs.Empty); }
return;
} else {
continue;
}
}
if (this.AllProfiles[i].DoNotCombineShows) { continue; }
if (isPrivateLobbies) {
if (!string.IsNullOrEmpty(this.AllProfiles[i].LinkedShowId) && string.Equals(this.AllProfiles[i].LinkedShowId, "private_lobbies")) {
ToolStripMenuItem item = this.ProfileMenuItems[this.AllProfiles.Count - 1 - i];
Expand All @@ -4901,20 +4942,35 @@ public void SetLinkedProfileMenu(string showId, bool isPrivateLobbies) {
}
}
if (isPrivateLobbies) { // select corresponding linked profile when possible if no linked "private_lobbies" profile was found
foreach (Profiles profiles in this.AllProfiles.FindAll(p => p.DoNotCombineShows)) {
if (!string.IsNullOrEmpty(profiles.LinkedShowId) && realShowId.IndexOf(profiles.LinkedShowId, StringComparison.OrdinalIgnoreCase) != -1) {
profileId = profiles.ProfileId;
isLinkedProfileFound = true;
break;
}
}
for (int j = 0; j < this.AllProfiles.Count; j++) {
if (string.IsNullOrEmpty(this.AllProfiles[j].LinkedShowId) || showId.IndexOf(this.AllProfiles[j].LinkedShowId, StringComparison.OrdinalIgnoreCase) == -1) {
continue;
if (isLinkedProfileFound) {
if (this.AllProfiles[j].ProfileId == profileId) {
ToolStripMenuItem item = this.ProfileMenuItems[this.AllProfiles.Count - 1 - j];
if (!item.Checked) { this.menuStats_Click(item, EventArgs.Empty); }
return;
} else {
continue;
}
} else {
if (this.AllProfiles[j].DoNotCombineShows || string.IsNullOrEmpty(this.AllProfiles[j].LinkedShowId) || showId.IndexOf(this.AllProfiles[j].LinkedShowId, StringComparison.OrdinalIgnoreCase) == -1) { continue; }

ToolStripMenuItem item = this.ProfileMenuItems[this.AllProfiles.Count - 1 - j];
if (!item.Checked) { this.menuStats_Click(item, EventArgs.Empty); }
return;
}

ToolStripMenuItem item = this.ProfileMenuItems[this.AllProfiles.Count - 1 - j];
if (!item.Checked) { this.menuStats_Click(item, EventArgs.Empty); }
return;
}
}
// select ProfileId 0 if no linked profile was found/matched
for (int k = 0; k < this.AllProfiles.Count; k++) {
if (this.AllProfiles[k].ProfileId != 0) { continue; }

ToolStripMenuItem item = this.ProfileMenuItems[this.AllProfiles.Count - 1 - k];
if (!item.Checked) { this.menuStats_Click(item, EventArgs.Empty); }
return;
Expand Down

0 comments on commit fc7c49f

Please sign in to comment.