Allow map slots to disallow bots
This commit is contained in:
@@ -20,7 +20,7 @@ namespace OpenRA.FileFormats
|
|||||||
public readonly IFolder Package;
|
public readonly IFolder Package;
|
||||||
|
|
||||||
// Yaml map data
|
// Yaml map data
|
||||||
public readonly string Uid;
|
public string Uid { get; protected set; }
|
||||||
[FieldLoader.Load] public bool Selectable;
|
[FieldLoader.Load] public bool Selectable;
|
||||||
|
|
||||||
[FieldLoader.Load] public string Title;
|
[FieldLoader.Load] public string Title;
|
||||||
@@ -37,7 +37,8 @@ namespace OpenRA.FileFormats
|
|||||||
[FieldLoader.Load] public int2 BottomRight;
|
[FieldLoader.Load] public int2 BottomRight;
|
||||||
public int Width { get { return BottomRight.X - TopLeft.X; } }
|
public int Width { get { return BottomRight.X - TopLeft.X; } }
|
||||||
public int Height { get { return BottomRight.Y - TopLeft.Y; } }
|
public int Height { get { return BottomRight.Y - TopLeft.Y; } }
|
||||||
|
|
||||||
|
public MapStub() {} // Hack for the editor - not used for anything important
|
||||||
public MapStub(IFolder package)
|
public MapStub(IFolder package)
|
||||||
{
|
{
|
||||||
Package = package;
|
Package = package;
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ namespace OpenRA.FileFormats
|
|||||||
public bool NonCombatant = false;
|
public bool NonCombatant = false;
|
||||||
public bool Playable = false;
|
public bool Playable = false;
|
||||||
public bool DefaultStartingUnits = false;
|
public bool DefaultStartingUnits = false;
|
||||||
|
public bool AllowBots = true;
|
||||||
public Color Color = Color.FromArgb(238,238,238);
|
public Color Color = Color.FromArgb(238,238,238);
|
||||||
public Color Color2 = Color.FromArgb(44,28,24);
|
public Color Color2 = Color.FromArgb(44,28,24);
|
||||||
|
|
||||||
|
|||||||
@@ -19,24 +19,14 @@ using OpenRA.FileFormats;
|
|||||||
|
|
||||||
namespace OpenRA
|
namespace OpenRA
|
||||||
{
|
{
|
||||||
public class Map
|
public class Map : MapStub
|
||||||
{
|
{
|
||||||
public IFolder Package;
|
|
||||||
public string Uid;
|
|
||||||
|
|
||||||
// Yaml map data
|
// Yaml map data
|
||||||
[FieldLoader.Load] public bool Selectable = true;
|
|
||||||
[FieldLoader.Load] public int MapFormat;
|
[FieldLoader.Load] public int MapFormat;
|
||||||
[FieldLoader.Load] public string Title;
|
|
||||||
[FieldLoader.Load] public string Description;
|
|
||||||
[FieldLoader.Load] public string Author;
|
|
||||||
[FieldLoader.Load] public int PlayerCount;
|
|
||||||
[FieldLoader.Load] public string Tileset;
|
|
||||||
|
|
||||||
public Dictionary<string, PlayerReference> Players = new Dictionary<string, PlayerReference>();
|
public Dictionary<string, PlayerReference> Players = new Dictionary<string, PlayerReference>();
|
||||||
public Dictionary<string, ActorReference> Actors = new Dictionary<string, ActorReference>();
|
public Dictionary<string, ActorReference> Actors = new Dictionary<string, ActorReference>();
|
||||||
public List<SmudgeReference> Smudges = new List<SmudgeReference>();
|
public List<SmudgeReference> Smudges = new List<SmudgeReference>();
|
||||||
public Dictionary<string, int2> Waypoints = new Dictionary<string, int2>();
|
|
||||||
|
|
||||||
// Rules overrides
|
// Rules overrides
|
||||||
public List<MiniYamlNode> Rules = new List<MiniYamlNode>();
|
public List<MiniYamlNode> Rules = new List<MiniYamlNode>();
|
||||||
@@ -45,8 +35,6 @@ namespace OpenRA
|
|||||||
public byte TileFormat = 1;
|
public byte TileFormat = 1;
|
||||||
[FieldLoader.Load] public int2 MapSize;
|
[FieldLoader.Load] public int2 MapSize;
|
||||||
|
|
||||||
[FieldLoader.Load] public int2 TopLeft;
|
|
||||||
[FieldLoader.Load] public int2 BottomRight;
|
|
||||||
|
|
||||||
public TileReference<ushort, byte>[,] MapTiles;
|
public TileReference<ushort, byte>[,] MapTiles;
|
||||||
public TileReference<byte, byte>[,] MapResources;
|
public TileReference<byte, byte>[,] MapResources;
|
||||||
@@ -55,10 +43,7 @@ namespace OpenRA
|
|||||||
// Temporary compat hacks
|
// Temporary compat hacks
|
||||||
public int XOffset { get { return TopLeft.X; } }
|
public int XOffset { get { return TopLeft.X; } }
|
||||||
public int YOffset { get { return TopLeft.Y; } }
|
public int YOffset { get { return TopLeft.Y; } }
|
||||||
public int Width { get { return BottomRight.X - TopLeft.X; } }
|
|
||||||
public int Height { get { return BottomRight.Y - TopLeft.Y; } }
|
|
||||||
public string Theater { get { return Tileset; } }
|
public string Theater { get { return Tileset; } }
|
||||||
public IEnumerable<int2> SpawnPoints { get { return Waypoints.Select(kv => kv.Value); } }
|
|
||||||
public Rectangle Bounds { get { return Rectangle.FromLTRB(TopLeft.X, TopLeft.Y, BottomRight.X, BottomRight.Y); } }
|
public Rectangle Bounds { get { return Rectangle.FromLTRB(TopLeft.X, TopLeft.Y, BottomRight.X, BottomRight.Y); } }
|
||||||
|
|
||||||
public Map()
|
public Map()
|
||||||
@@ -97,19 +82,13 @@ namespace OpenRA
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Map(IFolder package)
|
public Map(IFolder package)
|
||||||
|
: base(package)
|
||||||
{
|
{
|
||||||
Package = package;
|
|
||||||
var yaml = new MiniYaml( null, MiniYaml.FromStream( Package.GetContent( "map.yaml" ) ) );
|
var yaml = new MiniYaml( null, MiniYaml.FromStream( Package.GetContent( "map.yaml" ) ) );
|
||||||
|
|
||||||
// 'Simple' metadata
|
// 'Simple' metadata
|
||||||
FieldLoader.Load( this, yaml );
|
FieldLoader.Load( this, yaml );
|
||||||
|
|
||||||
// Waypoints
|
|
||||||
foreach (var wp in yaml.NodesDict["Waypoints"].NodesDict)
|
|
||||||
{
|
|
||||||
string[] loc = wp.Value.Value.Split(',');
|
|
||||||
Waypoints.Add(wp.Key, new int2(int.Parse(loc[0]), int.Parse(loc[1])));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Players & Actors -- this has changed several times.
|
// Players & Actors -- this has changed several times.
|
||||||
// - Be backwards compatible wherever possible.
|
// - Be backwards compatible wherever possible.
|
||||||
@@ -199,7 +178,6 @@ namespace OpenRA
|
|||||||
Rules = yaml.NodesDict["Rules"].Nodes;
|
Rules = yaml.NodesDict["Rules"].Nodes;
|
||||||
|
|
||||||
CustomTerrain = new string[MapSize.X, MapSize.Y];
|
CustomTerrain = new string[MapSize.X, MapSize.Y];
|
||||||
LoadUid();
|
|
||||||
LoadBinaryData();
|
LoadBinaryData();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -314,11 +292,6 @@ namespace OpenRA
|
|||||||
File.Move(filepath + ".tmp", filepath);
|
File.Move(filepath + ".tmp", filepath);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void LoadUid()
|
|
||||||
{
|
|
||||||
Uid = Package.GetContent("map.uid").ReadAllText();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SaveUid(string filename)
|
public void SaveUid(string filename)
|
||||||
{
|
{
|
||||||
// UID is calculated by taking an SHA1 of the yaml and binary data
|
// UID is calculated by taking an SHA1 of the yaml and binary data
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ namespace OpenRA.Widgets.Delegates
|
|||||||
|
|
||||||
Dictionary<string, string> CountryNames;
|
Dictionary<string, string> CountryNames;
|
||||||
string MapUid;
|
string MapUid;
|
||||||
MapStub Map;
|
Map Map;
|
||||||
|
|
||||||
public static Color CurrentColorPreview1;
|
public static Color CurrentColorPreview1;
|
||||||
public static Color CurrentColorPreview2;
|
public static Color CurrentColorPreview2;
|
||||||
@@ -109,6 +109,8 @@ namespace OpenRA.Widgets.Delegates
|
|||||||
orderManager.IssueOrder(Order.Command("startgame"));
|
orderManager.IssueOrder(Order.Command("startgame"));
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Todo: Only show if the map requirements are met for player slots
|
||||||
startGameButton.IsVisible = () => Game.IsHost;
|
startGameButton.IsVisible = () => Game.IsHost;
|
||||||
|
|
||||||
Game.LobbyInfoChanged += JoinedServer;
|
Game.LobbyInfoChanged += JoinedServer;
|
||||||
@@ -179,7 +181,7 @@ namespace OpenRA.Widgets.Delegates
|
|||||||
{
|
{
|
||||||
if (MapUid == orderManager.LobbyInfo.GlobalSettings.Map) return;
|
if (MapUid == orderManager.LobbyInfo.GlobalSettings.Map) return;
|
||||||
MapUid = orderManager.LobbyInfo.GlobalSettings.Map;
|
MapUid = orderManager.LobbyInfo.GlobalSettings.Map;
|
||||||
Map = Game.modData.AvailableMaps[MapUid];
|
Map = new Map(Game.modData.AvailableMaps[MapUid].Package);
|
||||||
|
|
||||||
var title = Widget.RootWidget.GetWidget<LabelWidget>("LOBBY_TITLE");
|
var title = Widget.RootWidget.GetWidget<LabelWidget>("LOBBY_TITLE");
|
||||||
title.Text = "OpenRA Multiplayer Lobby - " + orderManager.LobbyInfo.GlobalSettings.ServerName;
|
title.Text = "OpenRA Multiplayer Lobby - " + orderManager.LobbyInfo.GlobalSettings.ServerName;
|
||||||
@@ -242,7 +244,7 @@ namespace OpenRA.Widgets.Delegates
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (s.Bot == null)
|
if (s.Bot == null && Map.Players[s.MapPlayer].AllowBots)
|
||||||
orderManager.IssueOrder(Order.Command("slot_bot {0} HackyAI".F(s.Index)));
|
orderManager.IssueOrder(Order.Command("slot_bot {0} HackyAI".F(s.Index)));
|
||||||
else
|
else
|
||||||
orderManager.IssueOrder(Order.Command("slot_close " + s.Index));
|
orderManager.IssueOrder(Order.Command("slot_close " + s.Index));
|
||||||
|
|||||||
Reference in New Issue
Block a user