Remove fragile alliances feature.

This commit is contained in:
Paul Chote
2016-01-30 18:12:35 +00:00
parent aa491a35c8
commit 73b3f20921
21 changed files with 11 additions and 374 deletions

View File

@@ -63,7 +63,6 @@ namespace OpenRA
public bool? Fog;
public bool? Shroud;
public bool? AllyBuildRadius;
public bool? FragileAlliances;
public int? StartingCash;
public string TechLevel;
public bool ConfigurableStartingUnits = true;
@@ -86,8 +85,6 @@ namespace OpenRA
settings.AllyBuildRadius = AllyBuildRadius.Value;
if (StartingCash.HasValue)
settings.StartingCash = StartingCash.Value;
if (FragileAlliances.HasValue)
settings.FragileAlliances = FragileAlliances.Value;
if (ShortGame.HasValue)
settings.ShortGame = ShortGame.Value;
}

View File

@@ -179,7 +179,6 @@ namespace OpenRA.Network
public int Timestep = 40;
public int OrderLatency = 3; // net tick frames (x 120 = ms)
public int RandomSeed = 0;
public bool FragileAlliances = false; // Allow diplomatic stance changes after game start.
public bool AllowCheats = false;
public bool AllowSpectators = true;
public bool Dedicated;

View File

@@ -265,29 +265,6 @@ namespace OpenRA.Network
break;
}
case "SetStance":
{
if (!Game.OrderManager.LobbyInfo.GlobalSettings.FragileAlliances)
return;
var targetPlayer = order.Player.World.Players.FirstOrDefault(p => p.InternalName == order.TargetString);
var newStance = (Stance)order.ExtraData;
order.Player.SetStance(targetPlayer, newStance);
Game.Debug("{0} has set diplomatic stance vs {1} to {2}",
order.Player.PlayerName, targetPlayer.PlayerName, newStance);
// automatically declare war reciprocally
if (newStance == Stance.Enemy && targetPlayer.Stances[order.Player] == Stance.Ally)
{
targetPlayer.SetStance(order.Player, newStance);
Game.Debug("{0} has reciprocated", targetPlayer.PlayerName);
}
break;
}
case "Ping":
{
orderManager.IssueOrder(Order.Pong(order.TargetString));

View File

@@ -141,17 +141,6 @@ namespace OpenRA
return p == null || Stances[p] == Stance.Ally || (p.Spectating && !NonCombatant);
}
public void SetStance(Player target, Stance s)
{
var oldStance = Stances[target];
Stances[target] = s;
target.Shroud.UpdatePlayerStance(World, this, oldStance, s);
Shroud.UpdatePlayerStance(World, target, oldStance, s);
foreach (var nsc in World.ActorsWithTrait<INotifyStanceChanged>())
nsc.Trait.StanceChanged(nsc.Actor, this, target, oldStance, s);
}
public bool CanViewActor(Actor a)
{
return a.CanBeViewedByPlayer(this);

View File

@@ -364,12 +364,6 @@ namespace OpenRA.Traits
IEnumerable<WPos> TargetablePositions(Actor self);
}
public interface INotifyStanceChanged
{
void StanceChanged(Actor self, Player a, Player b,
Stance oldStance, Stance newStance);
}
public interface ILintPass { void Run(Action<string> emitError, Action<string> emitWarning); }
public interface ILintMapPass { void Run(Action<string> emitError, Action<string> emitWarning, Map map); }
public interface ILintRulesPass { void Run(Action<string> emitError, Action<string> emitWarning, Ruleset rules); }

View File

@@ -582,7 +582,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" />

View File

@@ -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);
}
}
}

View File

@@ -381,29 +381,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 =>
{

View File

@@ -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));

View File

@@ -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();
}
}
}

View File

@@ -372,15 +372,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)
{

View File

@@ -118,7 +118,7 @@ namespace OpenRA.Mods.RA.Traits
public override object Create(ActorInitializer init) { return new GpsPower(init.Self, this); }
}
class GpsPower : SupportPower, INotifyKilled, INotifyStanceChanged, INotifySold, INotifyOwnerChanged
class GpsPower : SupportPower, INotifyKilled, INotifySold, INotifyOwnerChanged
{
GpsWatcher owner;
@@ -159,11 +159,6 @@ namespace OpenRA.Mods.RA.Traits
owner.GpsRem(self);
}
public void StanceChanged(Actor self, Player a, Player b, Stance oldStance, Stance newStance)
{
owner.RefreshGps(self);
}
public void OnOwnerChanged(Actor self, Player oldOwner, Player newOwner)
{
RemoveGps(self);

View File

@@ -109,24 +109,6 @@ Container@PLAYER_WIDGETS:
X: 0
Y: 0
ImageCollection: order-icons
MenuButton@DIPLOMACY_BUTTON:
MenuContainer: INGAME_DIPLOMACY_BG
HideIngameUI: false
Pause: false
Key: P
X: 159
Width: 25
Height: 25
Background:
TooltipText: Diplomacy
TooltipContainer: TOOLTIP_CONTAINER
VisualHeight: 0
Children:
Image@ICON:
X: 0
Y: 0
ImageCollection: order-icons
ImageName: diplomacy
MenuButton@OPTIONS_BUTTON:
Key: escape
X: 78

View File

@@ -27,35 +27,29 @@ Background@LOBBY_OPTIONS_BIN:
Height: 20
Text: Fog of War
Checkbox@SHORTGAME_CHECKBOX:
X: 150
X: 180
Width: 140
Height: 20
Text: Short Game
Checkbox@CRATES_CHECKBOX:
X: 150
X: 180
Y: 35
Width: 140
Height: 20
Text: Crates
Checkbox@ALLYBUILDRADIUS_CHECKBOX:
X: 290
X: 350
Width: 140
Height: 20
Text: Build off Allies' ConYards
Checkbox@FRAGILEALLIANCES_CHECKBOX:
X: 290
Y: 35
Width: 140
Height: 20
Text: Diplomacy Changes
Checkbox@CREEPS_CHECKBOX:
Y: 70
Width: 140
Height: 20
Text: Worms
Checkbox@ALLOWCHEATS_CHECKBOX:
X: 150
Y: 70
X: 350
Y: 35
Width: 140
Height: 20
Text: Debug Menu

View File

@@ -69,7 +69,6 @@ Assemblies:
ChromeLayout:
d2k:chrome/ingame.yaml
./mods/ra/chrome/ingame-chat.yaml
./mods/ra/chrome/ingame-diplomacy.yaml
./mods/ra/chrome/ingame-fmvplayer.yaml
d2k:chrome/ingame-menu.yaml
./mods/ra/chrome/ingame-info.yaml

View File

@@ -1,91 +0,0 @@
Background@INGAME_DIPLOMACY_BG:
Logic: DiplomacyLogic
X: (WINDOW_RIGHT - WIDTH)/2
Y: (WINDOW_BOTTOM - HEIGHT)/2
Width: 490
Height: 355
Children:
Label@LABEL_TITLE:
X: (PARENT_RIGHT - WIDTH)/2
Y: 17
Width: 250
Height: 20
Text: Diplomacy
Align: Center
Font: Bold
Container@DIPLOMACY_HEADERS:
X: 20
Y: 40
Width: PARENT_RIGHT-40
Height: PARENT_BOTTOM
Children:
Label@PLAYER_HEADER:
X: 20
Width: 160
Height: 25
Font: Bold
Text: Player
Label@THEIR_STANCE_HEADER:
X: 210
Width: 80
Height: 25
Font: Bold
Text: Their Stance
Align: Center
Label@MY_STANCE_HEADER:
X: 307
Width: 100
Height: 25
Font: Bold
Text: My Stance
Align: Center
ScrollPanel@DIPLOMACY_PANEL:
X: 20
Y: 67
Width: PARENT_RIGHT-40
Height: PARENT_BOTTOM-87-35
TopBottomSpacing: 5
ItemSpacing: 5
Children:
ScrollItem@TEAM_TEMPLATE:
Width: PARENT_RIGHT
Height: 25
Children:
Label@TEAM:
X: 10
Width: PARENT_RIGHT
Height: PARENT_BOTTOM
Font: Bold
ScrollItem@PLAYER_TEMPLATE:
Width: PARENT_RIGHT-35
Height: 25
Children:
Image@FLAG:
X: 20
Y: 5
Width: 35
Height: PARENT_BOTTOM-5
ImageName: random
ImageCollection: flags
Label@PLAYER:
X: 55
Width: 160
Height: PARENT_BOTTOM
Font: Bold
Label@THEIR_STANCE:
X: 210
Width: 80
Height: PARENT_BOTTOM
Align: Center
DropDownButton@MY_STANCE:
X: 307
Width: 100
Height: PARENT_BOTTOM
Button@CLOSE:
X: PARENT_RIGHT-145
Y: PARENT_BOTTOM - 45
Width: 120
Height: 25
Text: Close
Key: escape
Font: Bold

View File

@@ -115,25 +115,6 @@ Container@PLAYER_WIDGETS:
Y: 6
ImageCollection: order-icons
ImageName: debug
MenuButton@DIPLOMACY_BUTTON:
Logic: AddFactionSuffixLogic
MenuContainer: INGAME_DIPLOMACY_BG
HideIngameUI: false
Pause: false
Key: P
X: 160
Width: 28
Height: 28
Background: sidebar-button
TooltipText: Diplomacy
TooltipContainer: TOOLTIP_CONTAINER
VisualHeight: 0
Children:
Image@ICON:
X: 6
Y: 6
ImageCollection: order-icons
ImageName: diplomacy
MenuButton@OPTIONS_BUTTON:
Logic: AddFactionSuffixLogic
Key: escape

View File

@@ -27,29 +27,24 @@ Background@LOBBY_OPTIONS_BIN:
Height: 20
Text: Fog of War
Checkbox@SHORTGAME_CHECKBOX:
X: 150
X: 180
Width: 140
Height: 20
Text: Short Game
Checkbox@CRATES_CHECKBOX:
X: 150
X: 180
Y: 35
Width: 140
Height: 20
Text: Crates
Checkbox@ALLYBUILDRADIUS_CHECKBOX:
X: 290
X: 350
Width: 140
Height: 20
Text: Build off Allies' ConYards
Checkbox@FRAGILEALLIANCES_CHECKBOX:
X: 290
Y: 35
Width: 140
Height: 20
Text: Diplomacy Changes
Checkbox@ALLOWCHEATS_CHECKBOX:
Y: 70
X: 350
Y: 35
Width: 140
Height: 20
Text: Debug Menu

View File

@@ -82,7 +82,6 @@ Assemblies:
ChromeLayout:
./mods/ra/chrome/ingame.yaml
./mods/ra/chrome/ingame-chat.yaml
./mods/ra/chrome/ingame-diplomacy.yaml
./mods/ra/chrome/ingame-fmvplayer.yaml
./mods/ra/chrome/ingame-info.yaml
./mods/ra/chrome/ingame-infoscripterror.yaml

View File

@@ -118,26 +118,6 @@ Container@PLAYER_WIDGETS:
X: 0
Y: 0
ImageCollection: order-icons
MenuButton@DIPLOMACY_BUTTON:
Logic: AddFactionSuffixLogic
MenuContainer: INGAME_DIPLOMACY_BG
HideIngameUI: false
Pause: false
Key: P
X: 163
Width: 30
Height: 31
Background: sidebar-button
TooltipText: Diplomacy
TooltipContainer: TOOLTIP_CONTAINER
VisualHeight: 0
Children:
Image@ICON:
Logic: AddFactionSuffixLogic
X: 0
Y: 0
ImageCollection: order-icons
ImageName: diplomacy
MenuButton@OPTIONS_BUTTON:
Logic: AddFactionSuffixLogic
Key: escape

View File

@@ -134,7 +134,6 @@ Assemblies:
ChromeLayout:
./mods/ra/chrome/ingame.yaml
./mods/ra/chrome/ingame-chat.yaml
./mods/ra/chrome/ingame-diplomacy.yaml
./mods/ra/chrome/ingame-fmvplayer.yaml
./mods/ra/chrome/ingame-menu.yaml
./mods/ts/chrome/ingame-info.yaml