Added more options for bots in RA game lobby
This commit is contained in:
@@ -75,7 +75,19 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
|
|
||||||
var owned = orderManager.LobbyInfo.Clients.Any(c => c.SpawnPoint == p);
|
var owned = orderManager.LobbyInfo.Clients.Any(c => c.SpawnPoint == p);
|
||||||
if (p == 0 || !owned)
|
if (p == 0 || !owned)
|
||||||
orderManager.IssueOrder(Order.Command("spawn {0} {1}".F(orderManager.LocalClient.Index, p)));
|
{
|
||||||
|
if (Game.IsHost)
|
||||||
|
{
|
||||||
|
var clients = orderManager.LobbyInfo.Slots.Keys.Select(k => orderManager.LobbyInfo.ClientInSlot(k)).ToList();
|
||||||
|
|
||||||
|
var locals = clients.Where(c => c != null && (c.Index == orderManager.LocalClient.Index || c.Bot != null));
|
||||||
|
|
||||||
|
var playerToMove = locals.Where(c => (p == 0) ? c.SpawnPoint != 0 : c.SpawnPoint == 0).FirstOrDefault();
|
||||||
|
orderManager.IssueOrder(Order.Command("spawn {0} {1}".F((playerToMove != null) ? playerToMove.Index : orderManager.LocalClient.Index, p)));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
orderManager.IssueOrder(Order.Command("spawn {0} {1}".F(orderManager.LocalClient.Index, p)));
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
mapPreview.SpawnColors = () =>
|
mapPreview.SpawnColors = () =>
|
||||||
@@ -184,12 +196,15 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
lobby.GetWidget<ChatDisplayWidget>("CHAT_DISPLAY").AddLine(c, from, text);
|
lobby.GetWidget<ChatDisplayWidget>("CHAT_DISPLAY").AddLine(c, from, text);
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdatePlayerColor(float hf, float sf, float lf, float r)
|
void UpdatePlayerColor(Session.Client client, float hf, float sf, float lf, float r)
|
||||||
{
|
{
|
||||||
var ramp = new ColorRamp((byte) (hf*255), (byte) (sf*255), (byte) (lf*255), (byte)(r*255));
|
var ramp = new ColorRamp((byte)(hf * 255), (byte)(sf * 255), (byte)(lf * 255), (byte)(r * 255));
|
||||||
Game.Settings.Player.ColorRamp = ramp;
|
if (client.Index == orderManager.LocalClient.Index)
|
||||||
Game.Settings.Save();
|
{
|
||||||
orderManager.IssueOrder(Order.Command("color {0} {1}".F(orderManager.LocalClient.Index, ramp)));
|
Game.Settings.Player.ColorRamp = ramp;
|
||||||
|
Game.Settings.Save();
|
||||||
|
}
|
||||||
|
orderManager.IssueOrder(Order.Command("color {0} {1}".F(client.Index, ramp)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdateColorPreview(float hf, float sf, float lf, float r)
|
void UpdateColorPreview(float hf, float sf, float lf, float r)
|
||||||
@@ -209,18 +224,18 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
|
|
||||||
void ShowColorDropDown(DropDownButtonWidget color, Session.Client client)
|
void ShowColorDropDown(DropDownButtonWidget color, Session.Client client)
|
||||||
{
|
{
|
||||||
var colorChooser = Game.modData.WidgetLoader.LoadWidget( new WidgetArgs() { {"worldRenderer", worldRenderer} }, null, "COLOR_CHOOSER" );
|
var colorChooser = Game.modData.WidgetLoader.LoadWidget(new WidgetArgs() { { "worldRenderer", worldRenderer } }, null, "COLOR_CHOOSER");
|
||||||
var hueSlider = colorChooser.GetWidget<SliderWidget>("HUE_SLIDER");
|
var hueSlider = colorChooser.GetWidget<SliderWidget>("HUE_SLIDER");
|
||||||
hueSlider.Value = orderManager.LocalClient.ColorRamp.H / 255f;
|
hueSlider.Value = client.ColorRamp.H / 255f;
|
||||||
|
|
||||||
var satSlider = colorChooser.GetWidget<SliderWidget>("SAT_SLIDER");
|
var satSlider = colorChooser.GetWidget<SliderWidget>("SAT_SLIDER");
|
||||||
satSlider.Value = orderManager.LocalClient.ColorRamp.S / 255f;
|
satSlider.Value = client.ColorRamp.S / 255f;
|
||||||
|
|
||||||
var lumSlider = colorChooser.GetWidget<SliderWidget>("LUM_SLIDER");
|
var lumSlider = colorChooser.GetWidget<SliderWidget>("LUM_SLIDER");
|
||||||
lumSlider.Value = orderManager.LocalClient.ColorRamp.L / 255f;
|
lumSlider.Value = client.ColorRamp.L / 255f;
|
||||||
|
|
||||||
var rangeSlider = colorChooser.GetWidget<SliderWidget>("RANGE_SLIDER");
|
var rangeSlider = colorChooser.GetWidget<SliderWidget>("RANGE_SLIDER");
|
||||||
rangeSlider.Value = orderManager.LocalClient.ColorRamp.R / 255f;
|
rangeSlider.Value = client.ColorRamp.R / 255f;
|
||||||
|
|
||||||
Action updateColorPreview = () => UpdateColorPreview(hueSlider.Value, satSlider.Value, lumSlider.Value, rangeSlider.Value);
|
Action updateColorPreview = () => UpdateColorPreview(hueSlider.Value, satSlider.Value, lumSlider.Value, rangeSlider.Value);
|
||||||
|
|
||||||
@@ -233,7 +248,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
colorChooser.GetWidget<ButtonWidget>("BUTTON_OK").OnClick = () =>
|
colorChooser.GetWidget<ButtonWidget>("BUTTON_OK").OnClick = () =>
|
||||||
{
|
{
|
||||||
updateColorPreview();
|
updateColorPreview();
|
||||||
UpdatePlayerColor(hueSlider.Value, satSlider.Value, lumSlider.Value, rangeSlider.Value);
|
UpdatePlayerColor(client, hueSlider.Value, satSlider.Value, lumSlider.Value, rangeSlider.Value);
|
||||||
color.RemovePanel();
|
color.RemovePanel();
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -252,7 +267,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
var c = orderManager.LobbyInfo.ClientInSlot(kv.Key);
|
var c = orderManager.LobbyInfo.ClientInSlot(kv.Key);
|
||||||
Widget template;
|
Widget template;
|
||||||
|
|
||||||
if (c == null || c.Bot != null)
|
if (c == null || (c.Bot != null && Game.IsHost == false))
|
||||||
{
|
{
|
||||||
if (Game.IsHost)
|
if (Game.IsHost)
|
||||||
{
|
{
|
||||||
@@ -277,10 +292,27 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
|
|
||||||
template.GetWidget<LabelWidget>("BOT").IsVisible = () => c != null;
|
template.GetWidget<LabelWidget>("BOT").IsVisible = () => c != null;
|
||||||
}
|
}
|
||||||
else if (c.Index == orderManager.LocalClient.Index && c.State != Session.ClientState.Ready)
|
|
||||||
|
else if ((c.Index == orderManager.LocalClient.Index && c.State != Session.ClientState.Ready) || (c.Bot != null && Game.IsHost))
|
||||||
{
|
{
|
||||||
template = LocalPlayerTemplate.Clone();
|
template = LocalPlayerTemplate.Clone();
|
||||||
LobbyUtils.SetupNameWidget(orderManager, c, template.GetWidget<TextFieldWidget>("NAME"));
|
|
||||||
|
var botReady = (c.Bot != null && Game.IsHost
|
||||||
|
&& orderManager.LocalClient.State == Session.ClientState.Ready);
|
||||||
|
var ready = botReady || c.State == Session.ClientState.Ready;
|
||||||
|
|
||||||
|
if (c.Bot == null)
|
||||||
|
{
|
||||||
|
LobbyUtils.SetupNameWidget(orderManager, c, template.GetWidget<TextFieldWidget>("NAME"));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var name = template.GetWidget<DropDownButtonWidget>("BOT_DROPDOWN");
|
||||||
|
name.IsVisible = () => true;
|
||||||
|
name.IsDisabled = () => ready;
|
||||||
|
name.GetText = () => c.Name;
|
||||||
|
name.OnMouseDown = _ => LobbyUtils.ShowSlotDropDown(name, s, c, orderManager);
|
||||||
|
}
|
||||||
|
|
||||||
var color = template.GetWidget<DropDownButtonWidget>("COLOR");
|
var color = template.GetWidget<DropDownButtonWidget>("COLOR");
|
||||||
color.IsDisabled = () => s.LockColor;
|
color.IsDisabled = () => s.LockColor;
|
||||||
@@ -307,6 +339,8 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
var status = template.GetWidget<CheckboxWidget>("STATUS");
|
var status = template.GetWidget<CheckboxWidget>("STATUS");
|
||||||
status.IsChecked = () => c.State == Session.ClientState.Ready;
|
status.IsChecked = () => c.State == Session.ClientState.Ready;
|
||||||
status.OnClick = CycleReady;
|
status.OnClick = CycleReady;
|
||||||
|
if (c.Bot != null) status.IsVisible = () => false;
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -52,6 +52,13 @@ Background@SERVER_LOBBY:
|
|||||||
X:0
|
X:0
|
||||||
Y:0
|
Y:0
|
||||||
MaxLength:16
|
MaxLength:16
|
||||||
|
DropDownButton@BOT_DROPDOWN:
|
||||||
|
Id:BOT_DROPDOWN
|
||||||
|
Text:Name
|
||||||
|
Width:150
|
||||||
|
Height:25
|
||||||
|
Font:Regular
|
||||||
|
Visible:false
|
||||||
DropDownButton@COLOR:
|
DropDownButton@COLOR:
|
||||||
Id:COLOR
|
Id:COLOR
|
||||||
Width:80
|
Width:80
|
||||||
|
|||||||
Reference in New Issue
Block a user