Skip to content

Commit

Permalink
#368 show colors in color drop down
Browse files Browse the repository at this point in the history
  • Loading branch information
devo1929 committed Sep 12, 2022
1 parent 624dfcc commit 51d39f1
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
11 changes: 8 additions & 3 deletions DXMainClient/DXGUI/Multiplayer/GameLobby/GameLobbyBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ public override void Initialize()
ddGameModeMapFilter.AddItem(CreateGameFilterItem(gm.UIName, new GameModeMapFilter(GetGameModeMaps(gm))));

lblGameModeSelect = FindChild<XNALabel>(nameof(lblGameModeSelect));

InitBtnMapSort();

tbMapSearch = FindChild<XNASuggestionTextBox>(nameof(tbMapSearch));
Expand Down Expand Up @@ -784,9 +784,14 @@ protected void InitPlayerOptionDropdowns()
ddPlayerColor.ClientRectangle = new Rectangle(
ddPlayerSide.Right + playerOptionHorizontalMargin,
ddPlayerName.Y, colorWidth, DROP_DOWN_HEIGHT);
ddPlayerColor.AddItem("Random".L10N("UI:Main:RandomColor"), AssetLoader.GetColorFromString(randomColor));
ddPlayerColor.AddItem(MultiplayerColor.GetRandomColorLabel(), AssetLoader.GetColorFromString(randomColor));
foreach (MultiplayerColor mpColor in MPColors)
ddPlayerColor.AddItem(mpColor.Name, mpColor.XnaColor);
{
if(mpColor.Name.StartsWith("$"))
ddPlayerColor.AddItem(string.Empty, AssetLoader.CreateTexture(mpColor.XnaColor, ddPlayerColor.Width - 2, ddPlayerColor.ItemHeight));
else
ddPlayerColor.AddItem(mpColor.Name, mpColor.XnaColor);
}
ddPlayerColor.AllowDropDown = false;
ddPlayerColor.SelectedIndexChanged += CopyPlayerDataFromUI;
ddPlayerColor.Tag = false;
Expand Down
12 changes: 12 additions & 0 deletions DXMainClient/Domain/Multiplayer/MultiplayerColor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Rampastring.Tools;
using System;
using System.Collections.Generic;
using Localization;

namespace DTAClient.Domain.Multiplayer
{
Expand All @@ -17,6 +18,10 @@ public class MultiplayerColor

private static List<MultiplayerColor> colorList;

private static string randomColorLabel;

private static readonly string RandomColorDefaultLabel = "Random".L10N("UI:Main:RandomSide");

/// <summary>
/// Creates a new multiplayer color from data in a string array.
/// </summary>
Expand Down Expand Up @@ -68,8 +73,15 @@ public static List<MultiplayerColor> LoadColors()
}
}

var randomColorSection = gameOptionsIni.GetSection("MPColorsRandomLabel");
if (randomColorSection != null)
randomColorLabel = randomColorSection.GetStringValue("Text", null);

colorList = mpColors;
return new List<MultiplayerColor>(colorList);
}

public static string GetRandomColorLabel()
=> string.IsNullOrEmpty(randomColorLabel) ? RandomColorDefaultLabel : randomColorLabel;
}
}
6 changes: 6 additions & 0 deletions DXMainClient/Resources/DTA/GameOptions.ini
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ ReservedStartingLocationAngularVelocity=0.01
RandomColor=136,121,114 ;189,166,111 matches civilian color

; The multiplayer colors. Syntax: <Name>=R,G,B,<in-game color ID>
; To show actual colors instead of color names/labels, prefix each key with "$"

[MPColors]
Gold=255,227,140,0
Red=222,77,49,1
Expand All @@ -24,6 +26,10 @@ White=255,255,255,15
Pink=255,20,169,35
Cyan=132,239,255,59 ;,53

[MPColorsRandomLabel]
; This is the text that will appear for the "Random" option in the color drop down
Text=Random

[MultiplayerGameLobby]
; Defines if a side or multiple sides need specific DropDown values to be usable.
; Each side needs 3 entries: side name, DropDown name, and DropDown value index.
Expand Down

0 comments on commit 51d39f1

Please sign in to comment.