Merge pull request #10650 from pchote/remove-fragile-diplomacy
Remove fragile diplomacy.
This commit is contained in:
@@ -581,7 +581,6 @@
|
||||
<Compile Include="Widgets\Logic\Ingame\ClassicProductionLogic.cs" />
|
||||
<Compile Include="Widgets\Logic\Ingame\ControlGroupLogic.cs" />
|
||||
<Compile Include="Widgets\Logic\Ingame\DebugMenuLogic.cs" />
|
||||
<Compile Include="Widgets\Logic\Ingame\DiplomacyLogic.cs" />
|
||||
<Compile Include="Widgets\Logic\Ingame\GameInfoBriefingLogic.cs" />
|
||||
<Compile Include="Widgets\Logic\Ingame\GameInfoLogic.cs" />
|
||||
<Compile Include="Widgets\Logic\Ingame\GameInfoObjectivesLogic.cs" />
|
||||
|
||||
@@ -24,13 +24,5 @@ namespace OpenRA.Mods.Common.Scripting
|
||||
{
|
||||
return Player.IsAlliedWith(targetPlayer);
|
||||
}
|
||||
|
||||
[Desc("Changes the current stance of the player against the target player. " +
|
||||
"Allowed keywords for new stance: Ally, Neutral, Enemy.")]
|
||||
public void SetStance(Player targetPlayer, string newStance)
|
||||
{
|
||||
var emergingStance = Enum<Stance>.Parse(newStance);
|
||||
Player.SetStance(targetPlayer, emergingStance);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -392,29 +392,6 @@ namespace OpenRA.Mods.Common.Server
|
||||
return true;
|
||||
}
|
||||
},
|
||||
{ "fragilealliance",
|
||||
s =>
|
||||
{
|
||||
if (!client.IsAdmin)
|
||||
{
|
||||
server.SendOrderTo(conn, "Message", "Only the host can set that option.");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (server.Map.Options.FragileAlliances.HasValue)
|
||||
{
|
||||
server.SendOrderTo(conn, "Message", "Map has disabled alliance configuration.");
|
||||
return true;
|
||||
}
|
||||
|
||||
bool.TryParse(s, out server.LobbyInfo.GlobalSettings.FragileAlliances);
|
||||
server.SyncLobbyGlobalSettings();
|
||||
server.SendMessage("{0} {1} Diplomacy Changes."
|
||||
.F(client.Name, server.LobbyInfo.GlobalSettings.FragileAlliances ? "enabled" : "disabled"));
|
||||
|
||||
return true;
|
||||
}
|
||||
},
|
||||
{ "allowcheats",
|
||||
s =>
|
||||
{
|
||||
|
||||
@@ -25,9 +25,6 @@ namespace OpenRA.Mods.Common.Server
|
||||
var defaults = new Session.Global();
|
||||
FieldLoader.Load(defaults, Game.ModData.Manifest.LobbyDefaults);
|
||||
|
||||
if (server.LobbyInfo.GlobalSettings.FragileAlliances != defaults.FragileAlliances)
|
||||
server.SendOrderTo(conn, "Message", "Diplomacy Changes: {0}".F(server.LobbyInfo.GlobalSettings.FragileAlliances));
|
||||
|
||||
if (server.LobbyInfo.GlobalSettings.AllowCheats != defaults.AllowCheats)
|
||||
server.SendOrderTo(conn, "Message", "Allow Cheats: {0}".F(server.LobbyInfo.GlobalSettings.AllowCheats));
|
||||
|
||||
|
||||
@@ -1,108 +0,0 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2015 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
* see COPYING.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using OpenRA.Network;
|
||||
using OpenRA.Traits;
|
||||
using OpenRA.Widgets;
|
||||
|
||||
namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
{
|
||||
public class DiplomacyLogic : ChromeLogic
|
||||
{
|
||||
readonly World world;
|
||||
|
||||
ScrollPanelWidget diplomacyPanel;
|
||||
|
||||
[ObjectCreator.UseCtor]
|
||||
public DiplomacyLogic(Widget widget, Action onExit, World world)
|
||||
{
|
||||
this.world = world;
|
||||
|
||||
diplomacyPanel = widget.Get<ScrollPanelWidget>("DIPLOMACY_PANEL");
|
||||
|
||||
LayoutPlayers();
|
||||
|
||||
var close = widget.GetOrNull<ButtonWidget>("CLOSE");
|
||||
if (close != null)
|
||||
close.OnClick = () =>
|
||||
{
|
||||
Ui.CloseWindow();
|
||||
Ui.Root.RemoveChild(widget);
|
||||
onExit();
|
||||
};
|
||||
}
|
||||
|
||||
void LayoutPlayers()
|
||||
{
|
||||
var teamTemplate = diplomacyPanel.Get<ScrollItemWidget>("TEAM_TEMPLATE");
|
||||
var players = world.Players.Where(p => p != world.LocalPlayer && !p.NonCombatant);
|
||||
var teams = players.GroupBy(p => (world.LobbyInfo.ClientWithIndex(p.ClientIndex) ?? new Session.Client()).Team).OrderBy(g => g.Key);
|
||||
foreach (var t in teams)
|
||||
{
|
||||
var team = t;
|
||||
var tt = ScrollItemWidget.Setup(teamTemplate, () => false, () => { });
|
||||
tt.IgnoreMouseOver = true;
|
||||
tt.Get<LabelWidget>("TEAM").GetText = () => team.Key == 0 ? "No Team" : "Team " + team.Key;
|
||||
diplomacyPanel.AddChild(tt);
|
||||
foreach (var p in team)
|
||||
{
|
||||
var player = p;
|
||||
diplomacyPanel.AddChild(DiplomaticStatus(player));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ScrollItemWidget DiplomaticStatus(Player player)
|
||||
{
|
||||
var playerTemplate = diplomacyPanel.Get<ScrollItemWidget>("PLAYER_TEMPLATE");
|
||||
var pt = ScrollItemWidget.Setup(playerTemplate, () => false, () => { });
|
||||
pt.IgnoreMouseOver = true;
|
||||
LobbyUtils.AddPlayerFlagAndName(pt, player);
|
||||
pt.Get<LabelWidget>("THEIR_STANCE").GetText = () => player.Stances[world.LocalPlayer].ToString();
|
||||
var myStance = pt.Get<DropDownButtonWidget>("MY_STANCE");
|
||||
myStance.GetText = () => world.LocalPlayer.Stances[player].ToString();
|
||||
myStance.IsDisabled = () => !world.LobbyInfo.GlobalSettings.FragileAlliances;
|
||||
myStance.OnMouseDown = mi => ShowDropDown(player, myStance);
|
||||
return pt;
|
||||
}
|
||||
|
||||
void ShowDropDown(Player p, DropDownButtonWidget dropdown)
|
||||
{
|
||||
var stances = Enum<Stance>.GetValues();
|
||||
Func<Stance, ScrollItemWidget, ScrollItemWidget> setupItem = (s, template) =>
|
||||
{
|
||||
var item = ScrollItemWidget.Setup(template,
|
||||
() => s == world.LocalPlayer.Stances[p],
|
||||
() => SetStance(dropdown, p, s));
|
||||
|
||||
item.Get<LabelWidget>("LABEL").GetText = () => s.ToString();
|
||||
return item;
|
||||
};
|
||||
|
||||
dropdown.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 150, stances, setupItem);
|
||||
}
|
||||
|
||||
void SetStance(ButtonWidget bw, Player p, Stance ss)
|
||||
{
|
||||
if (!p.World.LobbyInfo.GlobalSettings.FragileAlliances)
|
||||
return; // stance changes are banned
|
||||
|
||||
world.IssueOrder(new Order("SetStance", world.LocalPlayer.PlayerActor, false)
|
||||
{
|
||||
ExtraData = (uint)ss,
|
||||
TargetString = p.InternalName,
|
||||
});
|
||||
|
||||
bw.Text = ss.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -373,15 +373,6 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
"allybuildradius {0}".F(!orderManager.LobbyInfo.GlobalSettings.AllyBuildRadius)));
|
||||
}
|
||||
|
||||
var fragileAlliance = optionsBin.GetOrNull<CheckboxWidget>("FRAGILEALLIANCES_CHECKBOX");
|
||||
if (fragileAlliance != null)
|
||||
{
|
||||
fragileAlliance.IsChecked = () => orderManager.LobbyInfo.GlobalSettings.FragileAlliances;
|
||||
fragileAlliance.IsDisabled = () => Map.Status != MapStatus.Available || Map.Map.Options.FragileAlliances.HasValue || configurationDisabled();
|
||||
fragileAlliance.OnClick = () => orderManager.IssueOrder(Order.Command(
|
||||
"fragilealliance {0}".F(!orderManager.LobbyInfo.GlobalSettings.FragileAlliances)));
|
||||
}
|
||||
|
||||
var shortGame = optionsBin.GetOrNull<CheckboxWidget>("SHORTGAME_CHECKBOX");
|
||||
if (shortGame != null)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user