Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add optional parameter to [ForcedOptions] to make changes optional #643

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions DXMainClient/DXGUI/Multiplayer/GameLobby/GameLobbyBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -780,7 +780,7 @@
ddGameModeMapFilter.SelectedIndex = gameModeMapFilterIndex;
}

protected void AddSideToDropDown(XNADropDown dd, string name, string? uiName = null, Texture2D? texture = null)

Check warning on line 783 in DXMainClient/DXGUI/Multiplayer/GameLobby/GameLobbyBase.cs

View workflow job for this annotation

GitHub Actions / build-clients (Ares)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 783 in DXMainClient/DXGUI/Multiplayer/GameLobby/GameLobbyBase.cs

View workflow job for this annotation

GitHub Actions / build-clients (Ares)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 783 in DXMainClient/DXGUI/Multiplayer/GameLobby/GameLobbyBase.cs

View workflow job for this annotation

GitHub Actions / build-clients (TS)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 783 in DXMainClient/DXGUI/Multiplayer/GameLobby/GameLobbyBase.cs

View workflow job for this annotation

GitHub Actions / build-clients (TS)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 783 in DXMainClient/DXGUI/Multiplayer/GameLobby/GameLobbyBase.cs

View workflow job for this annotation

GitHub Actions / build-clients (YR)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 783 in DXMainClient/DXGUI/Multiplayer/GameLobby/GameLobbyBase.cs

View workflow job for this annotation

GitHub Actions / build-clients (YR)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.
{
XNADropDownItem item = new()
{
Expand Down Expand Up @@ -2235,22 +2235,24 @@

PlayerExtraOptionsPanel?.UpdateForMap(Map);
}

private void ApplyForcedCheckBoxOptions(List<GameLobbyCheckBox> optionList,
List<KeyValuePair<string, bool>> forcedOptions)
List<KeyValuePair<string, string>> forcedOptions)
{
foreach (KeyValuePair<string, bool> option in forcedOptions)
foreach (KeyValuePair<string, string> option in forcedOptions)
{
string[] optionParts = option.Value.Split(',');
GameLobbyCheckBox checkBox = CheckBoxes.Find(chk => chk.Name == option.Key);
if (checkBox != null)
{
checkBox.Checked = option.Value;
checkBox.AllowChecking = false;
checkBox.Checked = bool.Parse(optionParts[0]);
checkBox.AllowChecking = optionParts.Length > 1 ? bool.Parse(optionParts[1]) : false;

optionList.Remove(checkBox);
}
}
}


11EJDE11 marked this conversation as resolved.
Show resolved Hide resolved
private void ApplyForcedDropDownOptions(List<GameLobbyDropDown> optionList,
List<KeyValuePair<string, int>> forcedOptions)
{
Expand Down
4 changes: 2 additions & 2 deletions DXMainClient/Domain/Multiplayer/GameMode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public GameMode(string name)

public List<Map> Maps = new List<Map>();

public List<KeyValuePair<string, bool>> ForcedCheckBoxValues = new List<KeyValuePair<string, bool>>();
public List<KeyValuePair<string, string>> ForcedCheckBoxValues = new List<KeyValuePair<string, string>>();
public List<KeyValuePair<string, int>> ForcedDropDownValues = new List<KeyValuePair<string, int>>();

private List<KeyValuePair<string, string>> ForcedSpawnIniOptions = new List<KeyValuePair<string, string>>();
Expand Down Expand Up @@ -126,7 +126,7 @@ private void ParseForcedOptions(IniFile forcedOptionsIni)
}
else
{
ForcedCheckBoxValues.Add(new KeyValuePair<string, bool>(key, Conversions.BooleanFromString(value, false)));
ForcedCheckBoxValues.Add(new KeyValuePair<string, string>(key, value));
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions DXMainClient/Domain/Multiplayer/Map.cs
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ public void CalculateSHA()
public bool ExtractCustomPreview { get; set; } = true;

[JsonInclude]
public List<KeyValuePair<string, bool>> ForcedCheckBoxValues = new List<KeyValuePair<string, bool>>(0);
public List<KeyValuePair<string, string>> ForcedCheckBoxValues = new List<KeyValuePair<string, string>>(0);

[JsonInclude]
public List<KeyValuePair<string, int>> ForcedDropDownValues = new List<KeyValuePair<string, int>>(0);
Expand Down Expand Up @@ -664,7 +664,7 @@ private void ParseForcedOptions(IniFile iniFile, string forcedOptionsSection)
}
else
{
ForcedCheckBoxValues.Add(new KeyValuePair<string, bool>(key, Conversions.BooleanFromString(value, false)));
ForcedCheckBoxValues.Add(new KeyValuePair<string, string>(key, value));
}
}
}
Expand Down
Loading