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

Select & show preferred skill level when making a game #598

Merged
merged 14 commits into from
Jan 3, 2025

Conversation

GrantBartlett
Copy link
Member

@GrantBartlett GrantBartlett commented Dec 31, 2024

Simple icon indicator to show preferred skill level when making online games

Screenshots

Select player skill preference when hosting

image

Beginner

image

Intermediate

image

Pro

image

@GrantBartlett GrantBartlett changed the title First pass on hosts setting game difficulty preferences Select preferred skill level when making a game Dec 31, 2024
@GrantBartlett GrantBartlett changed the title Select preferred skill level when making a game Select & show preferred skill level when making a game Dec 31, 2024
Copy link

github-actions bot commented Dec 31, 2024

Nightly build for this pull request:

Copy link
Member

@SadPencil SadPencil left a comment

Choose a reason for hiding this comment

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

Does it come with the localization support?

@GrantBartlett
Copy link
Member Author

Does it come with the localization support?
public string OnlineGameDifficultyOptions => clientDefinitionsIni.GetStringValue(SETTINGS, "OnlineGameDifficultyOptions", "Any,Beginner,Intermediate,Pro (Competitive)");

Is there a way to have something like this but translated? If there is an example I can follow I can update it

@SadPencil
Copy link
Member

SadPencil commented Jan 3, 2025

Does it come with the localization support?
public string OnlineGameDifficultyOptions => clientDefinitionsIni.GetStringValue(SETTINGS, "OnlineGameDifficultyOptions", "Any,Beginner,Intermediate,Pro (Competitive)");

Is there a way to have something like this but translated? If there is an example I can follow I can update it

#598 (comment)

foreach(string difficulty in OnlineGameDifficultyOptions)
                ddGameDifficulty.AddItem(difficulty);

change it to something like:

for i, difficulty:
  string localizedDifficulty=difficulty.L10N("INI:ClientDefinitions:Difficulty{i}");

@@ -330,6 +330,8 @@ private List<TranslationGameFile> ParseTranslationGameFiles()

public string AllowedCustomGameModes => clientDefinitionsIni.GetStringValue(SETTINGS, "AllowedCustomGameModes", "Standard,Custom Map");

public string OnlineGameDifficultyOptions => clientDefinitionsIni.GetStringValue(SETTINGS, "OnlineGameDifficultyOptions", "Any,Beginner,Intermediate,Pro (Competitive)");
Copy link
Member

Choose a reason for hiding this comment

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

Pretty sure this should be an array or list of strings already.
Also I don't think you should be adding (competitive), just beginner/intermediate/pro is enough. Beginner games can be competitive too, and pro players can be playing casually for fun without any sweat.

DXMainClient/DXGUI/Multiplayer/GameListBox.cs Outdated Show resolved Hide resolved
DXMainClient/Program.cs Outdated Show resolved Hide resolved
Copy link
Member

@SadPencil SadPencil left a comment

Choose a reason for hiding this comment

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

Localization questions remain. Others are fine.

@@ -132,6 +142,8 @@ public void SetInfo(GenericHostedGame game)
{
lblPlayerNames[i].Visible = false;
}

lblGameDifficulty.Text = "Preferred Skill Level:".L10N("Client:Main:GameInfoDifficulty") + " " + OnlineGameDifficultyOptions[game.GameDifficulty];
Copy link
Member

Choose a reason for hiding this comment

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

Localization required

@@ -143,7 +143,8 @@ public void SetInfo(GenericHostedGame game)
lblPlayerNames[i].Visible = false;
}

lblGameDifficulty.Text = "Preferred Skill Level:".L10N("Client:Main:GameInfoDifficulty") + " " + OnlineGameDifficultyOptions[game.GameDifficulty];
lblGameDifficulty.Text = "Preferred Skill Level: ".L10N("Client:Main:GameInfoDifficulty")
+ " ".L10N($"INI:ClientDefinitions:Difficulty:{game.GameDifficulty}");
Copy link
Member

Choose a reason for hiding this comment

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

huh?

Comment on lines 206 to 213
if (gd != null)
{
txGameDifficultyIcons.Add(gd);
}
else
{
Logger.Log($"Failed to load texture for game difficulty index {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
if (gd != null)
{
txGameDifficultyIcons.Add(gd);
}
else
{
Logger.Log($"Failed to load texture for game difficulty index {i}");
}
if (gd != null)
txGameDifficultyIcons.Add(gd);
else
Logger.Log($"Failed to load texture for game difficulty index {i}");

@@ -332,6 +359,19 @@ public override void Draw(GameTime gameTime)
height, txPasswordedGame.Width, txPasswordedGame.Height),
Color.White);
}
else
{
Logger.Log("GameDifficulty ** Drawing game difficulty icon: " + hostedGame.GameDifficulty);
Copy link
Member

Choose a reason for hiding this comment

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

DO NOT

Suggested change
Logger.Log("GameDifficulty ** Drawing game difficulty icon: " + hostedGame.GameDifficulty);

Copy link
Member

Choose a reason for hiding this comment

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

If you need an explanation -- you're logging every single frame, this will absolutely tank the performance.

Comment on lines 369 to 372
DrawTexture(txGameDifficulty,
new Rectangle(Width - txGameDifficulty.Width - TextBorderDistance - (scrollBarDrawn ? ScrollBar.Width : 0),
height, txGameDifficulty.Width, txGameDifficulty.Height),
Color.White);
Copy link
Member

Choose a reason for hiding this comment

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

How does this look with locked/passworded/incompatible game icons?

Copy link
Member Author

Choose a reason for hiding this comment

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

For passworded games it doesn't show the icon. No need.
Incompatible/locked icons are on the left hand side.
The only icons on the right would be the difficulty icons OR password.

Copy link
Member

Choose a reason for hiding this comment

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

Right, but in future we should generalize this like RA2/YR icons implementation I've told you about earlier. The one where a broadcasted game option could add an icon, and every game option including those ones could draw an icon not impacting other game options.

Copy link
Member

Choose a reason for hiding this comment

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

"Any" should not have an icon at all IMO, it's "don't care" so shouldn't be the same as newbie icon.

Comment on lines 261 to 265
GameCreated?.Invoke(this,
new GameCreationEventArgs(gameName,int.Parse(ddMaxPlayers.SelectedItem.Text),
tbPassword.Text,tunnelHandler.Tunnels[lbTunnelList.SelectedIndex],
ddGameDifficulty.SelectedIndex)
);
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
GameCreated?.Invoke(this,
new GameCreationEventArgs(gameName,int.Parse(ddMaxPlayers.SelectedItem.Text),
tbPassword.Text,tunnelHandler.Tunnels[lbTunnelList.SelectedIndex],
ddGameDifficulty.SelectedIndex)
);
GameCreated?.Invoke(this,
new GameCreationEventArgs(gameName, int.Parse(ddMaxPlayers.SelectedItem.Text),
tbPassword.Text, tunnelHandler.Tunnels[lbTunnelList.SelectedIndex],
ddGameDifficulty.SelectedIndex)
);


string difficulty = OnlineGameDifficultyOptions[game.GameDifficulty];
string localizedDifficulty = difficulty.L10N($"INI:ClientDefinitions:Difficulty:{game.GameDifficulty}");
lblGameDifficulty.Text = "Preferred Skill Level: ".L10N("Client:Main:GameInfoDifficulty") + " " + localizedDifficulty;
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
lblGameDifficulty.Text = "Preferred Skill Level: ".L10N("Client:Main:GameInfoDifficulty") + " " + localizedDifficulty;
lblGameDifficulty.Text = "Preferred Skill Level:".L10N("Client:Main:GameInfoDifficulty") + " " + localizedDifficulty;

{
Texture2D txGameDifficulty = txGameDifficultyIcons[hostedGame.GameDifficulty];

if (txGameDifficulty != null && hostedGame.GameDifficulty > 0) // Don't show GameDifficulty Any
Copy link
Member

@Metadorius Metadorius Jan 3, 2025

Choose a reason for hiding this comment

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

No, why? You're making an assumption about what difficulties will be set by modder. You already have no image (or you should not have an image), why add an additional check?

Suggested change
if (txGameDifficulty != null && hostedGame.GameDifficulty > 0) // Don't show GameDifficulty Any
if (txGameDifficulty != null)

Copy link
Member

@Metadorius Metadorius left a comment

Choose a reason for hiding this comment

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

@Rampastring and myself think all references to "game difficulty" should be replaced with "preferred skill level" or just "skill level" as they are already in the text itself, but this also should be reflected on the code level and the INI level to not be confusing. Game difficulty usually is relevant in "against AI" scenarios, and skill level is more universal.

@SadPencil SadPencil merged commit ff5f14c into develop Jan 3, 2025
3 checks passed
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.

3 participants