New Command Order. GUI changes to settings no longer produce messages in chat. Can't enter commands in chat any more.
This commit is contained in:
@@ -182,6 +182,11 @@ namespace OpenRA
|
|||||||
return new Order("TeamChat", null, text) { IsImmediate = true };
|
return new Order("TeamChat", null, text) { IsImmediate = true };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Order Command(string text)
|
||||||
|
{
|
||||||
|
return new Order("Command", null, text) { IsImmediate = true };
|
||||||
|
}
|
||||||
|
|
||||||
public static Order StartProduction(Player subject, string item, int count)
|
public static Order StartProduction(Player subject, string item, int count)
|
||||||
{
|
{
|
||||||
return new Order("StartProduction", subject.PlayerActor, new int2( count, 0 ), item );
|
return new Order("StartProduction", subject.PlayerActor, new int2( count, 0 ), item );
|
||||||
|
|||||||
@@ -428,35 +428,24 @@ namespace OpenRA.Server
|
|||||||
{
|
{
|
||||||
switch (so.Name)
|
switch (so.Name)
|
||||||
{
|
{
|
||||||
case "Chat":
|
case "Command":
|
||||||
if (!HandleAsCommand(conn, so))
|
|
||||||
foreach (var c in conns.Except(conn).ToArray())
|
|
||||||
DispatchOrdersToClient(c, GetClient(conn).Index, 0, so.Serialize());
|
|
||||||
break;
|
|
||||||
//TODO: send to those with the same team
|
|
||||||
case "TeamChat":
|
|
||||||
if (!HandleAsCommand(conn, so))
|
|
||||||
foreach (var c in conns.Except(conn).ToArray())
|
|
||||||
DispatchOrdersToClient(c, GetClient(conn).Index, 0, so.Serialize());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool HandleAsCommand(Connection conn, ServerOrder so)
|
|
||||||
{
|
{
|
||||||
if (!so.Data.StartsWith("/")) return false;
|
|
||||||
|
|
||||||
var cmd = so.Data.Substring(1);
|
|
||||||
if(GameStarted)
|
if(GameStarted)
|
||||||
SendChatTo(conn, "Cannot change state when game started.");
|
SendChatTo(conn, "Cannot change state when game started.");
|
||||||
else if (GetClient(conn).State == Session.ClientState.Ready && cmd != "ready")
|
else if (GetClient(conn).State == Session.ClientState.Ready && so.Data != "ready")
|
||||||
SendChatTo(conn, "Cannot change state when marked as ready.");
|
SendChatTo(conn, "Cannot change state when marked as ready.");
|
||||||
else if (!InterpretCommand(conn, cmd))
|
else if (!InterpretCommand(conn, so.Data))
|
||||||
{
|
{
|
||||||
Console.WriteLine("Bad server command: {0}", cmd);
|
Console.WriteLine("Bad server command: {0}", so.Data);
|
||||||
SendChatTo(conn, "Bad server command.");
|
SendChatTo(conn, "Bad server command.");
|
||||||
|
};
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "Chat": case "TeamChat":
|
||||||
|
foreach (var c in conns.Except(conn).ToArray())
|
||||||
|
DispatchOrdersToClient(c, GetClient(conn).Index, 0, so.Serialize());
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static Session.Client GetClient(Connection conn)
|
static Session.Client GetClient(Connection conn)
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ namespace OpenRA.Widgets.Delegates
|
|||||||
{
|
{
|
||||||
var owned = Game.LobbyInfo.Clients.Any(c => c.SpawnPoint == sp);
|
var owned = Game.LobbyInfo.Clients.Any(c => c.SpawnPoint == sp);
|
||||||
if (sp == 0 || !owned)
|
if (sp == 0 || !owned)
|
||||||
Game.IssueOrder(Order.Chat("/spawn {0}".F(sp)));
|
Game.IssueOrder(Order.Command("spawn {0}".F(sp)));
|
||||||
};
|
};
|
||||||
|
|
||||||
map.SpawnColors = () =>
|
map.SpawnColors = () =>
|
||||||
@@ -95,8 +95,8 @@ namespace OpenRA.Widgets.Delegates
|
|||||||
lockTeamsCheckbox.OnMouseDown = mi =>
|
lockTeamsCheckbox.OnMouseDown = mi =>
|
||||||
{
|
{
|
||||||
if (Game.IsHost)
|
if (Game.IsHost)
|
||||||
Game.IssueOrder(Order.Chat(
|
Game.IssueOrder(Order.Command(
|
||||||
"/lockteams {0}".F(!Game.LobbyInfo.GlobalSettings.LockTeams)));
|
"lockteams {0}".F(!Game.LobbyInfo.GlobalSettings.LockTeams)));
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -162,7 +162,7 @@ namespace OpenRA.Widgets.Delegates
|
|||||||
if (name.Text == c.Name)
|
if (name.Text == c.Name)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
Game.IssueOrder(Order.Chat( "/name "+name.Text ));
|
Game.IssueOrder(Order.Command( "name "+name.Text ));
|
||||||
Game.Settings.PlayerName = name.Text;
|
Game.Settings.PlayerName = name.Text;
|
||||||
Game.Settings.Save();
|
Game.Settings.Save();
|
||||||
Chrome.selectedWidget = null;
|
Chrome.selectedWidget = null;
|
||||||
@@ -238,7 +238,7 @@ namespace OpenRA.Widgets.Delegates
|
|||||||
newIndex = (newIndex + d) % Game.world.PlayerColors().Count();
|
newIndex = (newIndex + d) % Game.world.PlayerColors().Count();
|
||||||
|
|
||||||
Game.IssueOrder(
|
Game.IssueOrder(
|
||||||
Order.Chat("/pal " + newIndex));
|
Order.Command("pal " + newIndex));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -258,7 +258,7 @@ namespace OpenRA.Widgets.Delegates
|
|||||||
if (nextCountry == null)
|
if (nextCountry == null)
|
||||||
nextCountry = countries.First();
|
nextCountry = countries.First();
|
||||||
|
|
||||||
Game.IssueOrder(Order.Chat("/race " + nextCountry));
|
Game.IssueOrder(Order.Command("race " + nextCountry));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -268,7 +268,7 @@ namespace OpenRA.Widgets.Delegates
|
|||||||
//HACK: Can't set this as part of the fuction as LocalClient/State not initalised yet
|
//HACK: Can't set this as part of the fuction as LocalClient/State not initalised yet
|
||||||
Chrome.rootWidget.GetWidget("SERVER_LOBBY").GetWidget<ButtonWidget>("CHANGEMAP_BUTTON").Visible
|
Chrome.rootWidget.GetWidget("SERVER_LOBBY").GetWidget<ButtonWidget>("CHANGEMAP_BUTTON").Visible
|
||||||
= (Game.IsHost && Game.LocalClient.State == Session.ClientState.Ready);
|
= (Game.IsHost && Game.LocalClient.State == Session.ClientState.Ready);
|
||||||
Game.IssueOrder(Order.Chat("/ready"));
|
Game.IssueOrder(Order.Command("ready"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -279,7 +279,7 @@ namespace OpenRA.Widgets.Delegates
|
|||||||
var newIndex = (Game.LocalClient.Team + d) % (Game.world.Map.PlayerCount+1);
|
var newIndex = (Game.LocalClient.Team + d) % (Game.world.Map.PlayerCount+1);
|
||||||
|
|
||||||
Game.IssueOrder(
|
Game.IssueOrder(
|
||||||
Order.Chat("/team " + newIndex));
|
Order.Command("team " + newIndex));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ namespace OpenRA.Widgets.Delegates
|
|||||||
bg.GetWidget<LabelWidget>("CURMAP_PLAYERS").GetText = () => {return Map.PlayerCount.ToString();};
|
bg.GetWidget<LabelWidget>("CURMAP_PLAYERS").GetText = () => {return Map.PlayerCount.ToString();};
|
||||||
|
|
||||||
bg.GetWidget("BUTTON_OK").OnMouseUp = mi => {
|
bg.GetWidget("BUTTON_OK").OnMouseUp = mi => {
|
||||||
Game.IssueOrder(Order.Chat("/map " + Map.Uid));
|
Game.IssueOrder(Order.Command("map " + Map.Uid));
|
||||||
r.CloseWindow();
|
r.CloseWindow();
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ namespace OpenRA
|
|||||||
localPlayerIndex = index;
|
localPlayerIndex = index;
|
||||||
if (Game.LobbyInfo.Clients.Count > 0 && !string.IsNullOrEmpty(Game.Settings.PlayerName)
|
if (Game.LobbyInfo.Clients.Count > 0 && !string.IsNullOrEmpty(Game.Settings.PlayerName)
|
||||||
&& Game.LobbyInfo.Clients[index].Name != Game.Settings.PlayerName)
|
&& Game.LobbyInfo.Clients[index].Name != Game.Settings.PlayerName)
|
||||||
Game.IssueOrder(Order.Chat("/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