Hook up the spawn selector.
This commit is contained in:
@@ -66,6 +66,7 @@ namespace OpenRA.Network
|
|||||||
public bool LockRace;
|
public bool LockRace;
|
||||||
public bool LockColor;
|
public bool LockColor;
|
||||||
public bool LockTeam;
|
public bool LockTeam;
|
||||||
|
public bool LockSpawn;
|
||||||
}
|
}
|
||||||
|
|
||||||
public class Global
|
public class Global
|
||||||
|
|||||||
@@ -355,11 +355,31 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
|
|||||||
return item;
|
return item;
|
||||||
};
|
};
|
||||||
|
|
||||||
var options = Graphics.Util.MakeArray(Map.PlayerCount, i => i).ToList();
|
var options = Graphics.Util.MakeArray(Map.SpawnPoints.Count()+1, i => i).ToList();
|
||||||
dropdown.ShowDropDown("TEAM_DROPDOWN_TEMPLATE", 150, options, setupItem);
|
dropdown.ShowDropDown("TEAM_DROPDOWN_TEMPLATE", 150, options, setupItem);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ShowSpawnDropDown(DropDownButtonWidget dropdown, Session.Client client)
|
||||||
|
{
|
||||||
|
Func<int, ScrollItemWidget, ScrollItemWidget> setupItem = (ii, itemTemplate) =>
|
||||||
|
{
|
||||||
|
var item = ScrollItemWidget.Setup(itemTemplate,
|
||||||
|
() => client.SpawnPoint == ii,
|
||||||
|
() => orderManager.IssueOrder(Order.Command("spawn {0} {1}".F(client.Index, ii))));
|
||||||
|
item.GetWidget<LabelWidget>("LABEL").GetText = () => ii == 0 ? "-" : ii.ToString();
|
||||||
|
return item;
|
||||||
|
};
|
||||||
|
|
||||||
|
var taken = orderManager.LobbyInfo.Clients
|
||||||
|
.Where(c => c.SpawnPoint != 0 && c.SpawnPoint != client.SpawnPoint && c.Slot != null)
|
||||||
|
.Select(c => c.SpawnPoint).ToList();
|
||||||
|
|
||||||
|
var options = Graphics.Util.MakeArray(Map.SpawnPoints.Count() + 1, i => i).Except(taken).ToList();
|
||||||
|
dropdown.ShowDropDown("TEAM_DROPDOWN_TEMPLATE", 150, options, setupItem);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool ShowColorDropDown(DropDownButtonWidget color, Session.Client client)
|
bool ShowColorDropDown(DropDownButtonWidget color, Session.Client client)
|
||||||
{
|
{
|
||||||
Action<ColorRamp> onSelect = c =>
|
Action<ColorRamp> onSelect = c =>
|
||||||
@@ -483,6 +503,11 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
|
|||||||
team.OnMouseDown = _ => { if (team.IsDisabled()) return true; return ShowTeamDropDown(team, client); };
|
team.OnMouseDown = _ => { if (team.IsDisabled()) return true; return ShowTeamDropDown(team, client); };
|
||||||
team.GetText = () => (client.Team == 0) ? "-" : client.Team.ToString();
|
team.GetText = () => (client.Team == 0) ? "-" : client.Team.ToString();
|
||||||
|
|
||||||
|
var spawn = template.GetWidget<DropDownButtonWidget>("SPAWN");
|
||||||
|
spawn.IsDisabled = () => slot.LockSpawn;
|
||||||
|
spawn.OnMouseDown = _ => { if (spawn.IsDisabled()) return true; return ShowSpawnDropDown(spawn, client); };
|
||||||
|
spawn.GetText = () => (client.SpawnPoint == 0) ? "-" : client.SpawnPoint.ToString();
|
||||||
|
|
||||||
if (client.Bot == null)
|
if (client.Bot == null)
|
||||||
{
|
{
|
||||||
// local player
|
// local player
|
||||||
@@ -493,7 +518,6 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
|
|||||||
}
|
}
|
||||||
else // Bot
|
else // Bot
|
||||||
template.GetWidget<ImageWidget>("STATUS_IMAGE").IsVisible = () => true;
|
template.GetWidget<ImageWidget>("STATUS_IMAGE").IsVisible = () => true;
|
||||||
|
|
||||||
}
|
}
|
||||||
// Non-editable player in slot
|
// Non-editable player in slot
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -321,7 +321,8 @@ namespace OpenRA.Mods.RA.Server
|
|||||||
AllowBots = pr.AllowBots,
|
AllowBots = pr.AllowBots,
|
||||||
LockRace = pr.LockRace,
|
LockRace = pr.LockRace,
|
||||||
LockColor = pr.LockColor,
|
LockColor = pr.LockColor,
|
||||||
LockTeam = false
|
LockTeam = false,
|
||||||
|
LockSpawn = false
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -94,7 +94,11 @@ namespace OpenRA.Mods.RA.Server
|
|||||||
return true;
|
return true;
|
||||||
|
|
||||||
// Spectators don't need a spawnpoint
|
// Spectators don't need a spawnpoint
|
||||||
if (client.Slot == null)
|
if (targetClient.Slot == null)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
// Map has disabled spawn changes
|
||||||
|
if (server.lobbyInfo.Slots[targetClient.Slot].LockSpawn)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
int spawnPoint;
|
int spawnPoint;
|
||||||
|
|||||||
Reference in New Issue
Block a user