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

#324 User defined auto ally presets #329

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

devo1929
Copy link
Contributor

Summary

Currently, users are limited to auto ally presets where pre-defined (whether in mpmaps.ini or in the .map files). This allows the user to create "user defined" presets as well as mark any preset (user defined or map) as the default for a given map.

User defined presets are prefixed with [U].

When a user has specified the default preset for a given map, that map will be auto selected when the map is changed and auto allying is enabled.

Custom user auto ally presets are stored at Client/AutoAllyUserPresets.ini


Drop down with custom preset and settings button
image

Example AutoAllyUserPresets.ini contents:

[Presets]
0=8WalledWorld112v2v2v2
1=4DesertIslandLE
2=4ColdestPeak
3=8MayflowerFreezesOver

[8WalledWorld112v2v2v2]
$$Default=2v2v2v2
2v2v2v2=A,A,B,B,C,C,D,D

[4DesertIslandLE]
my custom=A,B,x,A
test=A,B,x,A

[4ColdestPeak]
test=A,B,B,A

[8MayflowerFreezesOver]
4v4 Corners=A,A,B,B,A,A,B,B

Drop down opened with differing preset options
image

Edit preset with "create" option selected
image

Edit preset with existing option selected
image

Edit preset window drop down options
image

Edit button is disabled when auto allying is disabled
image

Help window:
image

@github-actions
Copy link

github-actions bot commented Apr 26, 2022

Nightly build for this pull request:

  • artifacts.zip
    This comment is automatic and is meant to allow guests to get latest automatic builds without registering. It is updated on every successful build.


namespace DTAClient.DXGUI.Multiplayer.CnCNet
{
public class TeamStartMappingPresetsWindow : XNAWindow
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure but maybe it's better to use the new INItializable window?

Comment on lines 192 to 195
private void RefreshDefaultCheckBox()
{
chkBoxSetDefault.Checked = SelectedTeamStartMappingPreset?.IsDefaultForMap ?? false;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expression body would be good here.

Comment on lines 273 to 274
"Are you sure you want to delete this preset?".L10N("UI:AutoAllyPresetWindow:ConfirmPresetDeleteText") + "\n\n" + selectedItem.Text);
messageBox.YesClickedAction = box =>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"Are you sure you want to delete this preset?".L10N("UI:AutoAllyPresetWindow:ConfirmPresetDeleteText") + "\n\n" + selectedItem.Text);
messageBox.YesClickedAction = box =>
"Are you sure you want to delete this preset?".L10N("UI:AutoAllyPresetWindow:ConfirmPresetDeleteText") + "\n\n" + selectedItem.Text);
messageBox.YesClickedAction = box =>

btnEditCustomPreset = new XNAClientButton(WindowManager);
btnEditCustomPreset.Name = nameof(btnEditCustomPreset);
btnEditCustomPreset.ClientRectangle = new Rectangle(ddTeamStartMappingPreset.Right + 2, ddTeamStartMappingPreset.Y, 22, 22);
btnEditCustomPreset.SetToolTipText("Edit".L10N("UI:Main:BtnEditAutoAllyPresetTooltip"));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably Edit is generic enough to not have such a complex L10N key.

var teamStartMappings = GetTeamStartMappings();
if (!teamStartMappings.Any())
{
XNAMessageBox.Show(WindowManager, "Cannot Save Presets", "Cannot save auto ally presets without any locations assigned.");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

L10N missing

btnSave = new XNAClientButton(WindowManager);
btnSave.Name = nameof(btnSave);
btnSave.LeftClick += BtnSave_LeftClick;
btnSave.Text = "Save".L10N("UI:AutoAllyPresetWindow:ButtonSave");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably could use the simple save key as the meaning is pretty generic.


btnDelete = new XNAClientButton(WindowManager);
btnDelete.Name = nameof(btnDelete);
btnDelete.Text = "Delete".L10N("UI:AutoAllyPresetWindow:ButtonDelete");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto


var btnCancel = new XNAClientButton(WindowManager);
btnCancel.Name = nameof(btnCancel);
btnCancel.Text = "Cancel".L10N("UI:AutoAllyPresetWindow:ButtonCancel");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto

Comment on lines 64 to 67
ddiCreatePresetItem.Text = "[Create New]".L10N("UI:AutoAllyPresetWindow:CreateNewPreset");

ddiSelectPresetItem = new XNADropDownItem();
ddiSelectPresetItem.Text = "[Select Preset]".L10N("UI:AutoAllyPresetWindow:SelectPreset");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think [ and ] need to be included in translation.

Comment on lines 89 to 90
List<string> mapNames = TeamStartMappingPresets.Keys.ToList();
for (int i = 0; i < mapNames.Count; i++)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
List<string> mapNames = TeamStartMappingPresets.Keys.ToList();
for (int i = 0; i < mapNames.Count; i++)
List<string> mapNames = TeamStartMappingPresets.Keys.ToList();
for (int i = 0; i < mapNames.Count; i++)

Comment on lines 122 to 125
AddOrUpdate(map.IniSafeName, preset);
if (!map.TeamStartMappingPresets.Contains(preset))
map.TeamStartMappingPresets.Add(preset);
Save();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
AddOrUpdate(map.IniSafeName, preset);
if (!map.TeamStartMappingPresets.Contains(preset))
map.TeamStartMappingPresets.Add(preset);
Save();
AddOrUpdate(map.IniSafeName, preset);
if (!map.TeamStartMappingPresets.Contains(preset))
map.TeamStartMappingPresets.Add(preset);
Save();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants