Rename boolean LobbyOption fields.
This commit is contained in:
@@ -180,13 +180,11 @@ namespace OpenRA.Network
|
|||||||
|
|
||||||
public class LobbyOptionState
|
public class LobbyOptionState
|
||||||
{
|
{
|
||||||
public bool Locked;
|
|
||||||
public string Value;
|
public string Value;
|
||||||
public string PreferredValue;
|
public string PreferredValue;
|
||||||
|
|
||||||
public LobbyOptionState() { }
|
public bool IsLocked;
|
||||||
|
public bool IsEnabled { get { return Value == "True"; } }
|
||||||
public bool Enabled { get { return Value == "True"; } }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class Global
|
public class Global
|
||||||
@@ -228,7 +226,7 @@ namespace OpenRA.Network
|
|||||||
{
|
{
|
||||||
LobbyOptionState option;
|
LobbyOptionState option;
|
||||||
if (LobbyOptions.TryGetValue(id, out option))
|
if (LobbyOptions.TryGetValue(id, out option))
|
||||||
return option.Enabled;
|
return option.IsEnabled;
|
||||||
|
|
||||||
return def;
|
return def;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -392,8 +392,8 @@ namespace OpenRA.Traits
|
|||||||
public readonly string Description;
|
public readonly string Description;
|
||||||
public readonly IReadOnlyDictionary<string, string> Values;
|
public readonly IReadOnlyDictionary<string, string> Values;
|
||||||
public readonly string DefaultValue;
|
public readonly string DefaultValue;
|
||||||
public readonly bool Locked;
|
public readonly bool IsLocked;
|
||||||
public readonly bool Visible;
|
public readonly bool IsVisible;
|
||||||
public readonly int DisplayOrder;
|
public readonly int DisplayOrder;
|
||||||
|
|
||||||
public LobbyOption(string id, string name, string description, bool visible, int displayorder,
|
public LobbyOption(string id, string name, string description, bool visible, int displayorder,
|
||||||
@@ -402,11 +402,11 @@ namespace OpenRA.Traits
|
|||||||
Id = id;
|
Id = id;
|
||||||
Name = name;
|
Name = name;
|
||||||
Description = description;
|
Description = description;
|
||||||
Visible = visible;
|
IsVisible = visible;
|
||||||
DisplayOrder = displayorder;
|
DisplayOrder = displayorder;
|
||||||
Values = values;
|
Values = values;
|
||||||
DefaultValue = defaultValue;
|
DefaultValue = defaultValue;
|
||||||
Locked = locked;
|
IsLocked = locked;
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual string ValueChangedMessage(string playerName, string newValue)
|
public virtual string ValueChangedMessage(string playerName, string newValue)
|
||||||
|
|||||||
@@ -464,7 +464,7 @@ namespace OpenRA.Mods.Common.Server
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (option.Locked)
|
if (option.IsLocked)
|
||||||
{
|
{
|
||||||
server.SendOrderTo(conn, "Message", "{0} cannot be changed.".F(option.Name));
|
server.SendOrderTo(conn, "Message", "{0} cannot be changed.".F(option.Name));
|
||||||
return true;
|
return true;
|
||||||
@@ -807,7 +807,7 @@ namespace OpenRA.Mods.Common.Server
|
|||||||
if (gs.LobbyOptions.TryGetValue(o.Id, out state))
|
if (gs.LobbyOptions.TryGetValue(o.Id, out state))
|
||||||
{
|
{
|
||||||
// Propagate old state on map change
|
// Propagate old state on map change
|
||||||
if (!o.Locked)
|
if (!o.IsLocked)
|
||||||
{
|
{
|
||||||
if (o.Values.Keys.Contains(state.PreferredValue))
|
if (o.Values.Keys.Contains(state.PreferredValue))
|
||||||
value = state.PreferredValue;
|
value = state.PreferredValue;
|
||||||
@@ -820,7 +820,7 @@ namespace OpenRA.Mods.Common.Server
|
|||||||
else
|
else
|
||||||
state = new Session.LobbyOptionState();
|
state = new Session.LobbyOptionState();
|
||||||
|
|
||||||
state.Locked = o.Locked;
|
state.IsLocked = o.IsLocked;
|
||||||
state.Value = value;
|
state.Value = value;
|
||||||
state.PreferredValue = preferredValue;
|
state.PreferredValue = preferredValue;
|
||||||
gs.LobbyOptions[o.Id] = state;
|
gs.LobbyOptions[o.Id] = state;
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
var allOptions = mapPreview.Rules.Actors["player"].TraitInfos<ILobbyOptions>()
|
var allOptions = mapPreview.Rules.Actors["player"].TraitInfos<ILobbyOptions>()
|
||||||
.Concat(mapPreview.Rules.Actors["world"].TraitInfos<ILobbyOptions>())
|
.Concat(mapPreview.Rules.Actors["world"].TraitInfos<ILobbyOptions>())
|
||||||
.SelectMany(t => t.LobbyOptions(mapPreview.Rules))
|
.SelectMany(t => t.LobbyOptions(mapPreview.Rules))
|
||||||
.Where(o => o.Visible)
|
.Where(o => o.IsVisible)
|
||||||
.OrderBy(o => o.DisplayOrder)
|
.OrderBy(o => o.DisplayOrder)
|
||||||
.ToArray();
|
.ToArray();
|
||||||
|
|
||||||
@@ -110,10 +110,10 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
checkbox.GetTooltipText = () => option.Description;
|
checkbox.GetTooltipText = () => option.Description;
|
||||||
|
|
||||||
checkbox.IsVisible = () => true;
|
checkbox.IsVisible = () => true;
|
||||||
checkbox.IsChecked = () => optionValue.Update(orderManager.LobbyInfo.GlobalSettings).Enabled;
|
checkbox.IsChecked = () => optionValue.Update(orderManager.LobbyInfo.GlobalSettings).IsEnabled;
|
||||||
checkbox.IsDisabled = () => configurationDisabled() || optionValue.Update(orderManager.LobbyInfo.GlobalSettings).Locked;
|
checkbox.IsDisabled = () => configurationDisabled() || optionValue.Update(orderManager.LobbyInfo.GlobalSettings).IsLocked;
|
||||||
checkbox.OnClick = () => orderManager.IssueOrder(Order.Command(
|
checkbox.OnClick = () => orderManager.IssueOrder(Order.Command(
|
||||||
"option {0} {1}".F(option.Id, !optionValue.Update(orderManager.LobbyInfo.GlobalSettings).Enabled)));
|
"option {0} {1}".F(option.Id, !optionValue.Update(orderManager.LobbyInfo.GlobalSettings).IsEnabled)));
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var option in allOptions.Where(o => !(o is LobbyBooleanOption)))
|
foreach (var option in allOptions.Where(o => !(o is LobbyBooleanOption)))
|
||||||
@@ -148,7 +148,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
dropdown.GetTooltipText = () => option.Description;
|
dropdown.GetTooltipText = () => option.Description;
|
||||||
dropdown.IsVisible = () => true;
|
dropdown.IsVisible = () => true;
|
||||||
dropdown.IsDisabled = () => configurationDisabled() ||
|
dropdown.IsDisabled = () => configurationDisabled() ||
|
||||||
optionValue.Update(orderManager.LobbyInfo.GlobalSettings).Locked;
|
optionValue.Update(orderManager.LobbyInfo.GlobalSettings).IsLocked;
|
||||||
|
|
||||||
dropdown.OnMouseDown = _ =>
|
dropdown.OnMouseDown = _ =>
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user