Store last color setting; hook server join in a cleaner way
This commit is contained in:
@@ -56,6 +56,9 @@ namespace OpenRA.GameRules
|
|||||||
public string LastServer = "localhost:1234";
|
public string LastServer = "localhost:1234";
|
||||||
public string Replay = null;
|
public string Replay = null;
|
||||||
public string PlayerName = "Newbie";
|
public string PlayerName = "Newbie";
|
||||||
|
public Color PlayerColor1 = Color.FromArgb(255,160,238);
|
||||||
|
public Color PlayerColor2 = Color.FromArgb(68,0,56);
|
||||||
|
|
||||||
public string[] InitialMods = { "ra" };
|
public string[] InitialMods = { "ra" };
|
||||||
|
|
||||||
// Server settings
|
// Server settings
|
||||||
|
|||||||
@@ -21,7 +21,8 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using OpenRA.FileFormats;
|
using OpenRA.FileFormats;
|
||||||
|
using OpenRA.Network;
|
||||||
using OpenRA.Traits;
|
using OpenRA.Traits;
|
||||||
|
|
||||||
namespace OpenRA.Widgets.Delegates
|
namespace OpenRA.Widgets.Delegates
|
||||||
@@ -104,7 +105,7 @@ namespace OpenRA.Widgets.Delegates
|
|||||||
"lockteams {0}".F(!Game.LobbyInfo.GlobalSettings.LockTeams)));
|
"lockteams {0}".F(!Game.LobbyInfo.GlobalSettings.LockTeams)));
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
Game.LobbyInfoChanged += JoinedServer;
|
||||||
Game.LobbyInfoChanged += UpdatePlayerList;
|
Game.LobbyInfoChanged += UpdatePlayerList;
|
||||||
Game.AddChatLine += lobby.GetWidget<ChatDisplayWidget>("CHAT_DISPLAY").AddLine;
|
Game.AddChatLine += lobby.GetWidget<ChatDisplayWidget>("CHAT_DISPLAY").AddLine;
|
||||||
|
|
||||||
@@ -158,6 +159,10 @@ namespace OpenRA.Widgets.Delegates
|
|||||||
{
|
{
|
||||||
var c1 = ColorFromHSL(hf, sf, lf);
|
var c1 = ColorFromHSL(hf, sf, lf);
|
||||||
var c2 = ColorFromHSL(hf, sf, r*lf);
|
var c2 = ColorFromHSL(hf, sf, r*lf);
|
||||||
|
|
||||||
|
Game.Settings.PlayerColor1 = c1;
|
||||||
|
Game.Settings.PlayerColor2 = c2;
|
||||||
|
Game.Settings.Save();
|
||||||
Game.IssueOrder(Order.Command("color {0},{1},{2},{3},{4},{5}".F(c1.R,c1.G,c1.B,c2.R,c2.G,c2.B)));
|
Game.IssueOrder(Order.Command("color {0},{1},{2},{3},{4},{5}".F(c1.R,c1.G,c1.B,c2.R,c2.G,c2.B)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -204,7 +209,25 @@ namespace OpenRA.Widgets.Delegates
|
|||||||
MapUid = Game.LobbyInfo.GlobalSettings.Map;
|
MapUid = Game.LobbyInfo.GlobalSettings.Map;
|
||||||
Map = Game.AvailableMaps[MapUid];
|
Map = Game.AvailableMaps[MapUid];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool hasJoined = false;
|
||||||
|
void JoinedServer()
|
||||||
|
{
|
||||||
|
if (hasJoined)
|
||||||
|
return;
|
||||||
|
hasJoined = true;
|
||||||
|
|
||||||
|
if (Game.LocalClient.Name != Game.Settings.PlayerName)
|
||||||
|
Game.IssueOrder(Order.Command("name " + Game.Settings.PlayerName));
|
||||||
|
|
||||||
|
if (Game.LocalClient.Color1 != Game.Settings.PlayerColor1 || Game.LocalClient.Color2 != Game.Settings.PlayerColor2)
|
||||||
|
{
|
||||||
|
var c1 = Game.Settings.PlayerColor1;
|
||||||
|
var c2 = Game.Settings.PlayerColor2;
|
||||||
|
Game.IssueOrder(Order.Command("color {0},{1},{2},{3},{4},{5}".F(c1.R,c1.G,c1.B,c2.R,c2.G,c2.B)));
|
||||||
|
}
|
||||||
|
}
|
||||||
void UpdatePlayerList()
|
void UpdatePlayerList()
|
||||||
{
|
{
|
||||||
// This causes problems for people who are in the process of editing their names (the widgets vanish from beneath them)
|
// This causes problems for people who are in the process of editing their names (the widgets vanish from beneath them)
|
||||||
|
|||||||
@@ -55,9 +55,6 @@ namespace OpenRA
|
|||||||
public void SetLocalPlayer(int index)
|
public void SetLocalPlayer(int index)
|
||||||
{
|
{
|
||||||
localPlayerIndex = index;
|
localPlayerIndex = index;
|
||||||
if (Game.LobbyInfo.Clients.Count > 0 && !string.IsNullOrEmpty(Game.Settings.PlayerName)
|
|
||||||
&& Game.LobbyInfo.Clients[index].Name != Game.Settings.PlayerName)
|
|
||||||
Game.IssueOrder(Order.Command("name " + Game.Settings.PlayerName));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public readonly Actor WorldActor;
|
public readonly Actor WorldActor;
|
||||||
|
|||||||
Reference in New Issue
Block a user