Fix IDE0039
This commit is contained in:
@@ -174,6 +174,9 @@ dotnet_diagnostic.IDE0034.severity = warning
|
|||||||
# Modifiers are not ordered.
|
# Modifiers are not ordered.
|
||||||
dotnet_diagnostic.IDE0036.severity = warning
|
dotnet_diagnostic.IDE0036.severity = warning
|
||||||
|
|
||||||
|
# Use local function instead of lambda.
|
||||||
|
dotnet_diagnostic.IDE0039.severity = warning
|
||||||
|
|
||||||
# Raise a warning on build when default access modifiers are explicitly specified.
|
# Raise a warning on build when default access modifiers are explicitly specified.
|
||||||
dotnet_diagnostic.IDE0040.severity = warning
|
dotnet_diagnostic.IDE0040.severity = warning
|
||||||
|
|
||||||
|
|||||||
@@ -270,15 +270,14 @@ namespace OpenRA
|
|||||||
{
|
{
|
||||||
OrderManager om = null;
|
OrderManager om = null;
|
||||||
|
|
||||||
Action lobbyReady = null;
|
void LobbyReady()
|
||||||
lobbyReady = () =>
|
|
||||||
{
|
{
|
||||||
LobbyInfoChanged -= lobbyReady;
|
LobbyInfoChanged -= LobbyReady;
|
||||||
foreach (var o in setupOrders)
|
foreach (var o in setupOrders)
|
||||||
om.IssueOrder(o);
|
om.IssueOrder(o);
|
||||||
};
|
}
|
||||||
|
|
||||||
LobbyInfoChanged += lobbyReady;
|
LobbyInfoChanged += LobbyReady;
|
||||||
|
|
||||||
om = JoinServer(CreateLocalServer(mapUID), "");
|
om = JoinServer(CreateLocalServer(mapUID), "");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -124,7 +124,7 @@ namespace OpenRA
|
|||||||
var fs = modData.DefaultFileSystem;
|
var fs = modData.DefaultFileSystem;
|
||||||
|
|
||||||
Ruleset ruleset = null;
|
Ruleset ruleset = null;
|
||||||
Action f = () =>
|
void LoadRuleset()
|
||||||
{
|
{
|
||||||
var actors = MergeOrDefault("Manifest,Rules", fs, m.Rules, null, null,
|
var actors = MergeOrDefault("Manifest,Rules", fs, m.Rules, null, null,
|
||||||
k => new ActorInfo(modData.ObjectCreator, k.Key.ToLowerInvariant(), k.Value),
|
k => new ActorInfo(modData.ObjectCreator, k.Key.ToLowerInvariant(), k.Value),
|
||||||
@@ -147,13 +147,13 @@ namespace OpenRA
|
|||||||
|
|
||||||
// The default ruleset does not include a preferred tileset or sequence set
|
// The default ruleset does not include a preferred tileset or sequence set
|
||||||
ruleset = new Ruleset(actors, weapons, voices, notifications, music, null, null, modelSequences);
|
ruleset = new Ruleset(actors, weapons, voices, notifications, music, null, null, modelSequences);
|
||||||
};
|
}
|
||||||
|
|
||||||
if (modData.IsOnMainThread)
|
if (modData.IsOnMainThread)
|
||||||
{
|
{
|
||||||
modData.HandleLoadingProgress();
|
modData.HandleLoadingProgress();
|
||||||
|
|
||||||
var loader = new Task(f);
|
var loader = new Task(LoadRuleset);
|
||||||
loader.Start();
|
loader.Start();
|
||||||
|
|
||||||
// Animate the loadscreen while we wait
|
// Animate the loadscreen while we wait
|
||||||
@@ -161,7 +161,7 @@ namespace OpenRA
|
|||||||
modData.HandleLoadingProgress();
|
modData.HandleLoadingProgress();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
f();
|
LoadRuleset();
|
||||||
|
|
||||||
return ruleset;
|
return ruleset;
|
||||||
}
|
}
|
||||||
@@ -183,7 +183,7 @@ namespace OpenRA
|
|||||||
var dr = modData.DefaultRules;
|
var dr = modData.DefaultRules;
|
||||||
|
|
||||||
Ruleset ruleset = null;
|
Ruleset ruleset = null;
|
||||||
Action f = () =>
|
void LoadRuleset()
|
||||||
{
|
{
|
||||||
var actors = MergeOrDefault("Rules", fileSystem, m.Rules, mapRules, dr.Actors,
|
var actors = MergeOrDefault("Rules", fileSystem, m.Rules, mapRules, dr.Actors,
|
||||||
k => new ActorInfo(modData.ObjectCreator, k.Key.ToLowerInvariant(), k.Value),
|
k => new ActorInfo(modData.ObjectCreator, k.Key.ToLowerInvariant(), k.Value),
|
||||||
@@ -214,13 +214,13 @@ namespace OpenRA
|
|||||||
k => k);
|
k => k);
|
||||||
|
|
||||||
ruleset = new Ruleset(actors, weapons, voices, notifications, music, terrainInfo, sequences, modelSequences);
|
ruleset = new Ruleset(actors, weapons, voices, notifications, music, terrainInfo, sequences, modelSequences);
|
||||||
};
|
}
|
||||||
|
|
||||||
if (modData.IsOnMainThread)
|
if (modData.IsOnMainThread)
|
||||||
{
|
{
|
||||||
modData.HandleLoadingProgress();
|
modData.HandleLoadingProgress();
|
||||||
|
|
||||||
var loader = new Task(f);
|
var loader = new Task(LoadRuleset);
|
||||||
loader.Start();
|
loader.Start();
|
||||||
|
|
||||||
// Animate the loadscreen while we wait
|
// Animate the loadscreen while we wait
|
||||||
@@ -228,7 +228,7 @@ namespace OpenRA
|
|||||||
modData.HandleLoadingProgress();
|
modData.HandleLoadingProgress();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
f();
|
LoadRuleset();
|
||||||
|
|
||||||
return ruleset;
|
return ruleset;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -480,17 +480,17 @@ namespace OpenRA
|
|||||||
AllEdgeCells = UpdateEdgeCells();
|
AllEdgeCells = UpdateEdgeCells();
|
||||||
|
|
||||||
// Invalidate the entry for a cell if anything could cause the terrain index to change.
|
// Invalidate the entry for a cell if anything could cause the terrain index to change.
|
||||||
Action<CPos> invalidateTerrainIndex = c =>
|
void InvalidateTerrainIndex(CPos c)
|
||||||
{
|
{
|
||||||
if (cachedTerrainIndexes != null)
|
if (cachedTerrainIndexes != null)
|
||||||
cachedTerrainIndexes[c] = InvalidCachedTerrainIndex;
|
cachedTerrainIndexes[c] = InvalidCachedTerrainIndex;
|
||||||
};
|
}
|
||||||
|
|
||||||
// Even though the cache is lazily initialized, we must attach these event handlers on init.
|
// Even though the cache is lazily initialized, we must attach these event handlers on init.
|
||||||
// This ensures our handler to invalidate the cache runs first,
|
// This ensures our handler to invalidate the cache runs first,
|
||||||
// so other listeners to these same events will get correct data when calling GetTerrainIndex.
|
// so other listeners to these same events will get correct data when calling GetTerrainIndex.
|
||||||
CustomTerrain.CellEntryChanged += invalidateTerrainIndex;
|
CustomTerrain.CellEntryChanged += InvalidateTerrainIndex;
|
||||||
Tiles.CellEntryChanged += invalidateTerrainIndex;
|
Tiles.CellEntryChanged += InvalidateTerrainIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdateRamp(CPos cell)
|
void UpdateRamp(CPos cell)
|
||||||
|
|||||||
@@ -37,24 +37,24 @@ namespace OpenRA.Server
|
|||||||
var status = cache[map];
|
var status = cache[map];
|
||||||
var failed = false;
|
var failed = false;
|
||||||
|
|
||||||
Action<string> onLintFailure = message =>
|
void OnLintFailure(string message)
|
||||||
{
|
{
|
||||||
Log.Write("server", "Map {0} failed lint with error: {1}", map.Title, message);
|
Log.Write("server", "Map {0} failed lint with error: {1}", map.Title, message);
|
||||||
failed = true;
|
failed = true;
|
||||||
};
|
}
|
||||||
|
|
||||||
Action<string> onLintWarning = _ => { };
|
void OnLintWarning(string _) { }
|
||||||
|
|
||||||
foreach (var customMapPassType in modData.ObjectCreator.GetTypesImplementing<ILintServerMapPass>())
|
foreach (var customMapPassType in modData.ObjectCreator.GetTypesImplementing<ILintServerMapPass>())
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var customMapPass = (ILintServerMapPass)modData.ObjectCreator.CreateBasic(customMapPassType);
|
var customMapPass = (ILintServerMapPass)modData.ObjectCreator.CreateBasic(customMapPassType);
|
||||||
customMapPass.Run(onLintFailure, onLintWarning, modData, map, rules);
|
customMapPass.Run(OnLintFailure, OnLintWarning, modData, map, rules);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
onLintFailure(e.ToString());
|
OnLintFailure(e.ToString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -541,7 +541,7 @@ namespace OpenRA.Server
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Action completeConnection = () =>
|
void CompleteConnection()
|
||||||
{
|
{
|
||||||
lock (LobbyInfo)
|
lock (LobbyInfo)
|
||||||
{
|
{
|
||||||
@@ -602,13 +602,13 @@ namespace OpenRA.Server
|
|||||||
else if (Map.Players.Players.Where(p => p.Value.Playable).All(p => !p.Value.AllowBots))
|
else if (Map.Players.Players.Where(p => p.Value.Playable).All(p => !p.Value.AllowBots))
|
||||||
SendLocalizedMessageTo(newConn, BotsDisabled);
|
SendLocalizedMessageTo(newConn, BotsDisabled);
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
if (Type == ServerType.Local)
|
if (Type == ServerType.Local)
|
||||||
{
|
{
|
||||||
// Local servers can only be joined by the local client, so we can trust their identity without validation
|
// Local servers can only be joined by the local client, so we can trust their identity without validation
|
||||||
client.Fingerprint = handshake.Fingerprint;
|
client.Fingerprint = handshake.Fingerprint;
|
||||||
completeConnection();
|
CompleteConnection();
|
||||||
}
|
}
|
||||||
else if (!string.IsNullOrEmpty(handshake.Fingerprint) && !string.IsNullOrEmpty(handshake.AuthSignature))
|
else if (!string.IsNullOrEmpty(handshake.Fingerprint) && !string.IsNullOrEmpty(handshake.AuthSignature))
|
||||||
{
|
{
|
||||||
@@ -678,7 +678,7 @@ namespace OpenRA.Server
|
|||||||
DropClient(newConn);
|
DropClient(newConn);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
completeConnection();
|
CompleteConnection();
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -691,7 +691,7 @@ namespace OpenRA.Server
|
|||||||
DropClient(newConn);
|
DropClient(newConn);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
completeConnection();
|
CompleteConnection();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
|||||||
@@ -93,9 +93,9 @@ namespace OpenRA
|
|||||||
|
|
||||||
this.loaders = loaders;
|
this.loaders = loaders;
|
||||||
this.fileSystem = fileSystem;
|
this.fileSystem = fileSystem;
|
||||||
Func<ISoundFormat, ISoundSource> loadIntoMemory = soundFormat => soundEngine.AddSoundSourceFromMemory(
|
ISoundSource LoadIntoMemory(ISoundFormat soundFormat) => soundEngine.AddSoundSourceFromMemory(
|
||||||
soundFormat.GetPCMInputStream().ReadAllBytes(), soundFormat.Channels, soundFormat.SampleBits, soundFormat.SampleRate);
|
soundFormat.GetPCMInputStream().ReadAllBytes(), soundFormat.Channels, soundFormat.SampleBits, soundFormat.SampleRate);
|
||||||
sounds = new Cache<string, ISoundSource>(filename => LoadSound(filename, loadIntoMemory));
|
sounds = new Cache<string, ISoundSource>(filename => LoadSound(filename, LoadIntoMemory));
|
||||||
currentSounds.Clear();
|
currentSounds.Clear();
|
||||||
currentNotifications.Clear();
|
currentNotifications.Clear();
|
||||||
video = null;
|
video = null;
|
||||||
@@ -252,11 +252,11 @@ namespace OpenRA
|
|||||||
|
|
||||||
StopMusic();
|
StopMusic();
|
||||||
|
|
||||||
Func<ISoundFormat, ISound> stream = soundFormat => soundEngine.Play2DStream(
|
ISound Stream(ISoundFormat soundFormat) => soundEngine.Play2DStream(
|
||||||
soundFormat.GetPCMInputStream(), soundFormat.Channels, soundFormat.SampleBits, soundFormat.SampleRate,
|
soundFormat.GetPCMInputStream(), soundFormat.Channels, soundFormat.SampleBits, soundFormat.SampleRate,
|
||||||
looped, true, WPos.Zero, MusicVolume * m.VolumeModifier);
|
looped, true, WPos.Zero, MusicVolume * m.VolumeModifier);
|
||||||
|
|
||||||
music = LoadSound(m.Filename, stream);
|
music = LoadSound(m.Filename, Stream);
|
||||||
if (music == null)
|
if (music == null)
|
||||||
{
|
{
|
||||||
onMusicComplete = null;
|
onMusicComplete = null;
|
||||||
|
|||||||
@@ -35,15 +35,15 @@ namespace OpenRA.Mods.Cnc.Graphics
|
|||||||
static SheetBuilder CreateSheetBuilder()
|
static SheetBuilder CreateSheetBuilder()
|
||||||
{
|
{
|
||||||
var allocated = false;
|
var allocated = false;
|
||||||
Func<Sheet> allocate = () =>
|
Sheet Allocate()
|
||||||
{
|
{
|
||||||
if (allocated)
|
if (allocated)
|
||||||
throw new SheetOverflowException("");
|
throw new SheetOverflowException("");
|
||||||
allocated = true;
|
allocated = true;
|
||||||
return SheetBuilder.AllocateSheet(SheetType.Indexed, Game.Settings.Graphics.SheetSize);
|
return SheetBuilder.AllocateSheet(SheetType.Indexed, Game.Settings.Graphics.SheetSize);
|
||||||
};
|
}
|
||||||
|
|
||||||
return new SheetBuilder(SheetType.Indexed, allocate);
|
return new SheetBuilder(SheetType.Indexed, Allocate);
|
||||||
}
|
}
|
||||||
|
|
||||||
public VoxelLoader(IReadOnlyFileSystem fileSystem)
|
public VoxelLoader(IReadOnlyFileSystem fileSystem)
|
||||||
@@ -99,7 +99,7 @@ namespace OpenRA.Mods.Cnc.Graphics
|
|||||||
|
|
||||||
IEnumerable<Vertex[]> GenerateSlicePlanes(VxlLimb l)
|
IEnumerable<Vertex[]> GenerateSlicePlanes(VxlLimb l)
|
||||||
{
|
{
|
||||||
Func<int, int, int, VxlElement> get = (x, y, z) =>
|
VxlElement Get(int x, int y, int z)
|
||||||
{
|
{
|
||||||
if (x < 0 || y < 0 || z < 0)
|
if (x < 0 || y < 0 || z < 0)
|
||||||
return null;
|
return null;
|
||||||
@@ -112,7 +112,7 @@ namespace OpenRA.Mods.Cnc.Graphics
|
|||||||
return null;
|
return null;
|
||||||
|
|
||||||
return l.VoxelMap[(byte)x, (byte)y][(byte)z];
|
return l.VoxelMap[(byte)x, (byte)y][(byte)z];
|
||||||
};
|
}
|
||||||
|
|
||||||
// Cull slices without any visible faces
|
// Cull slices without any visible faces
|
||||||
var xPlanes = new bool[l.Size[0] + 1];
|
var xPlanes = new bool[l.Size[0] + 1];
|
||||||
@@ -124,23 +124,23 @@ namespace OpenRA.Mods.Cnc.Graphics
|
|||||||
{
|
{
|
||||||
for (var z = 0; z < l.Size[2]; z++)
|
for (var z = 0; z < l.Size[2]; z++)
|
||||||
{
|
{
|
||||||
if (get(x, y, z) == null)
|
if (Get(x, y, z) == null)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// Only generate a plane if it is actually visible
|
// Only generate a plane if it is actually visible
|
||||||
if (!xPlanes[x] && get(x - 1, y, z) == null)
|
if (!xPlanes[x] && Get(x - 1, y, z) == null)
|
||||||
xPlanes[x] = true;
|
xPlanes[x] = true;
|
||||||
if (!xPlanes[x + 1] && get(x + 1, y, z) == null)
|
if (!xPlanes[x + 1] && Get(x + 1, y, z) == null)
|
||||||
xPlanes[x + 1] = true;
|
xPlanes[x + 1] = true;
|
||||||
|
|
||||||
if (!yPlanes[y] && get(x, y - 1, z) == null)
|
if (!yPlanes[y] && Get(x, y - 1, z) == null)
|
||||||
yPlanes[y] = true;
|
yPlanes[y] = true;
|
||||||
if (!yPlanes[y + 1] && get(x, y + 1, z) == null)
|
if (!yPlanes[y + 1] && Get(x, y + 1, z) == null)
|
||||||
yPlanes[y + 1] = true;
|
yPlanes[y + 1] = true;
|
||||||
|
|
||||||
if (!zPlanes[z] && get(x, y, z - 1) == null)
|
if (!zPlanes[z] && Get(x, y, z - 1) == null)
|
||||||
zPlanes[z] = true;
|
zPlanes[z] = true;
|
||||||
if (!zPlanes[z + 1] && get(x, y, z + 1) == null)
|
if (!zPlanes[z + 1] && Get(x, y, z + 1) == null)
|
||||||
zPlanes[z + 1] = true;
|
zPlanes[z + 1] = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -149,22 +149,22 @@ namespace OpenRA.Mods.Cnc.Graphics
|
|||||||
for (var x = 0; x <= l.Size[0]; x++)
|
for (var x = 0; x <= l.Size[0]; x++)
|
||||||
if (xPlanes[x])
|
if (xPlanes[x])
|
||||||
yield return GenerateSlicePlane(l.Size[1], l.Size[2],
|
yield return GenerateSlicePlane(l.Size[1], l.Size[2],
|
||||||
(u, v) => get(x, u, v),
|
(u, v) => Get(x, u, v),
|
||||||
(u, v) => get(x - 1, u, v),
|
(u, v) => Get(x - 1, u, v),
|
||||||
(u, v) => new float3(x, u, v));
|
(u, v) => new float3(x, u, v));
|
||||||
|
|
||||||
for (var y = 0; y <= l.Size[1]; y++)
|
for (var y = 0; y <= l.Size[1]; y++)
|
||||||
if (yPlanes[y])
|
if (yPlanes[y])
|
||||||
yield return GenerateSlicePlane(l.Size[0], l.Size[2],
|
yield return GenerateSlicePlane(l.Size[0], l.Size[2],
|
||||||
(u, v) => get(u, y, v),
|
(u, v) => Get(u, y, v),
|
||||||
(u, v) => get(u, y - 1, v),
|
(u, v) => Get(u, y - 1, v),
|
||||||
(u, v) => new float3(u, y, v));
|
(u, v) => new float3(u, y, v));
|
||||||
|
|
||||||
for (var z = 0; z <= l.Size[2]; z++)
|
for (var z = 0; z <= l.Size[2]; z++)
|
||||||
if (zPlanes[z])
|
if (zPlanes[z])
|
||||||
yield return GenerateSlicePlane(l.Size[0], l.Size[1],
|
yield return GenerateSlicePlane(l.Size[0], l.Size[1],
|
||||||
(u, v) => get(u, v, z),
|
(u, v) => Get(u, v, z),
|
||||||
(u, v) => get(u, v, z - 1),
|
(u, v) => Get(u, v, z - 1),
|
||||||
(u, v) => new float3(u, v, z));
|
(u, v) => new float3(u, v, z));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,6 @@
|
|||||||
*/
|
*/
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using OpenRA.Graphics;
|
using OpenRA.Graphics;
|
||||||
@@ -38,14 +37,14 @@ namespace OpenRA.Mods.Cnc.Traits
|
|||||||
|
|
||||||
public void LoadPalettes(WorldRenderer wr)
|
public void LoadPalettes(WorldRenderer wr)
|
||||||
{
|
{
|
||||||
Func<int, uint> makeColor = i =>
|
uint MakeColor(int i)
|
||||||
{
|
{
|
||||||
if (i < 128)
|
if (i < 128)
|
||||||
return (uint)(int2.Lerp(255, 0, i, 127) << 24);
|
return (uint)(int2.Lerp(255, 0, i, 127) << 24);
|
||||||
return 0;
|
return 0;
|
||||||
};
|
}
|
||||||
|
|
||||||
wr.AddPalette(info.Name, new ImmutablePalette(Enumerable.Range(0, Palette.Size).Select(i => makeColor(i))));
|
wr.AddPalette(info.Name, new ImmutablePalette(Enumerable.Range(0, Palette.Size).Select(i => MakeColor(i))));
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<string> PaletteNames { get { yield return info.Name; } }
|
public IEnumerable<string> PaletteNames { get { yield return info.Name; } }
|
||||||
|
|||||||
@@ -9,7 +9,6 @@
|
|||||||
*/
|
*/
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@@ -257,16 +256,16 @@ namespace OpenRA.Mods.Common.Widgets
|
|||||||
var mapTiles = map.Tiles;
|
var mapTiles = map.Tiles;
|
||||||
var replace = mapTiles[cell];
|
var replace = mapTiles[cell];
|
||||||
|
|
||||||
Action<CPos> maybeEnqueue = newCell =>
|
void MaybeEnqueue(CPos newCell)
|
||||||
{
|
{
|
||||||
if (map.Contains(cell) && !touched[newCell])
|
if (map.Contains(cell) && !touched[newCell])
|
||||||
{
|
{
|
||||||
queue.Enqueue(newCell);
|
queue.Enqueue(newCell);
|
||||||
touched[newCell] = true;
|
touched[newCell] = true;
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
Func<CPos, bool> shouldPaint = cellToCheck =>
|
bool ShouldPaint(CPos cellToCheck)
|
||||||
{
|
{
|
||||||
for (var y = 0; y < terrainTemplate.Size.Y; y++)
|
for (var y = 0; y < terrainTemplate.Size.Y; y++)
|
||||||
{
|
{
|
||||||
@@ -279,28 +278,28 @@ namespace OpenRA.Mods.Common.Widgets
|
|||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
};
|
}
|
||||||
|
|
||||||
Func<CPos, CVec, CPos> findEdge = (refCell, direction) =>
|
CPos FindEdge(CPos refCell, CVec direction)
|
||||||
{
|
{
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
var newCell = refCell + direction;
|
var newCell = refCell + direction;
|
||||||
if (!shouldPaint(newCell))
|
if (!ShouldPaint(newCell))
|
||||||
return refCell;
|
return refCell;
|
||||||
refCell = newCell;
|
refCell = newCell;
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
queue.Enqueue(cell);
|
queue.Enqueue(cell);
|
||||||
while (queue.Count > 0)
|
while (queue.Count > 0)
|
||||||
{
|
{
|
||||||
var queuedCell = queue.Dequeue();
|
var queuedCell = queue.Dequeue();
|
||||||
if (!shouldPaint(queuedCell))
|
if (!ShouldPaint(queuedCell))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
var previousCell = findEdge(queuedCell, new CVec(-1 * terrainTemplate.Size.X, 0));
|
var previousCell = FindEdge(queuedCell, new CVec(-1 * terrainTemplate.Size.X, 0));
|
||||||
var nextCell = findEdge(queuedCell, new CVec(1 * terrainTemplate.Size.X, 0));
|
var nextCell = FindEdge(queuedCell, new CVec(1 * terrainTemplate.Size.X, 0));
|
||||||
|
|
||||||
for (var x = previousCell.X; x <= nextCell.X; x += terrainTemplate.Size.X)
|
for (var x = previousCell.X; x <= nextCell.X; x += terrainTemplate.Size.X)
|
||||||
{
|
{
|
||||||
@@ -308,10 +307,10 @@ namespace OpenRA.Mods.Common.Widgets
|
|||||||
var upperCell = new CPos(x, queuedCell.Y - (1 * terrainTemplate.Size.Y));
|
var upperCell = new CPos(x, queuedCell.Y - (1 * terrainTemplate.Size.Y));
|
||||||
var lowerCell = new CPos(x, queuedCell.Y + (1 * terrainTemplate.Size.Y));
|
var lowerCell = new CPos(x, queuedCell.Y + (1 * terrainTemplate.Size.Y));
|
||||||
|
|
||||||
if (shouldPaint(upperCell))
|
if (ShouldPaint(upperCell))
|
||||||
maybeEnqueue(upperCell);
|
MaybeEnqueue(upperCell);
|
||||||
if (shouldPaint(lowerCell))
|
if (ShouldPaint(lowerCell))
|
||||||
maybeEnqueue(lowerCell);
|
MaybeEnqueue(lowerCell);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -330,7 +330,7 @@ namespace OpenRA.Mods.Common.Graphics
|
|||||||
var offset = LoadField(Offset, data, defaults);
|
var offset = LoadField(Offset, data, defaults);
|
||||||
var blendMode = LoadField(BlendMode, data, defaults);
|
var blendMode = LoadField(BlendMode, data, defaults);
|
||||||
|
|
||||||
Func<int, IEnumerable<int>> getUsedFrames = frameCount =>
|
IEnumerable<int> GetUsedFrames(int frameCount)
|
||||||
{
|
{
|
||||||
if (LoadField(Length.Key, "", data, defaults) == "*")
|
if (LoadField(Length.Key, "", data, defaults) == "*")
|
||||||
length = frames?.Length ?? frameCount - start;
|
length = frames?.Length ?? frameCount - start;
|
||||||
@@ -387,7 +387,7 @@ namespace OpenRA.Mods.Common.Graphics
|
|||||||
return usedFrames.Concat(usedFrames.Select(i => i + shadowStart - start));
|
return usedFrames.Concat(usedFrames.Select(i => i + shadowStart - start));
|
||||||
|
|
||||||
return usedFrames;
|
return usedFrames;
|
||||||
};
|
}
|
||||||
|
|
||||||
var combineNode = data.Nodes.FirstOrDefault(n => n.Key == Combine.Key);
|
var combineNode = data.Nodes.FirstOrDefault(n => n.Key == Combine.Key);
|
||||||
if (combineNode != null)
|
if (combineNode != null)
|
||||||
@@ -406,7 +406,7 @@ namespace OpenRA.Mods.Common.Graphics
|
|||||||
var subFrames = LoadField(Frames, combineData, NoData);
|
var subFrames = LoadField(Frames, combineData, NoData);
|
||||||
var subLength = 0;
|
var subLength = 0;
|
||||||
|
|
||||||
Func<int, IEnumerable<int>> subGetUsedFrames = subFrameCount =>
|
IEnumerable<int> SubGetUsedFrames(int subFrameCount)
|
||||||
{
|
{
|
||||||
var combineLengthNode = combineData.Nodes.FirstOrDefault(n => n.Key == Length.Key);
|
var combineLengthNode = combineData.Nodes.FirstOrDefault(n => n.Key == Length.Key);
|
||||||
if (combineLengthNode?.Value.Value == "*")
|
if (combineLengthNode?.Value.Value == "*")
|
||||||
@@ -415,13 +415,13 @@ namespace OpenRA.Mods.Common.Graphics
|
|||||||
subLength = LoadField(Length, combineData, NoData);
|
subLength = LoadField(Length, combineData, NoData);
|
||||||
|
|
||||||
return subFrames != null ? subFrames.Skip(subStart).Take(subLength) : Enumerable.Range(subStart, subLength);
|
return subFrames != null ? subFrames.Skip(subStart).Take(subLength) : Enumerable.Range(subStart, subLength);
|
||||||
};
|
}
|
||||||
|
|
||||||
var subFilename = GetSpriteFilename(modData, tileSet, image, sequence, combineData, NoData);
|
var subFilename = GetSpriteFilename(modData, tileSet, image, sequence, combineData, NoData);
|
||||||
if (subFilename == null)
|
if (subFilename == null)
|
||||||
throw new YamlException($"Sequence {image}.{sequence}.{combineSequenceNode.Key} does not define a filename.");
|
throw new YamlException($"Sequence {image}.{sequence}.{combineSequenceNode.Key} does not define a filename.");
|
||||||
|
|
||||||
var subSprites = cache[subFilename, subGetUsedFrames].Select(s =>
|
var subSprites = cache[subFilename, SubGetUsedFrames].Select(s =>
|
||||||
{
|
{
|
||||||
if (s == null)
|
if (s == null)
|
||||||
return null;
|
return null;
|
||||||
@@ -439,7 +439,7 @@ namespace OpenRA.Mods.Common.Graphics
|
|||||||
}
|
}
|
||||||
|
|
||||||
sprites = combined.ToArray();
|
sprites = combined.ToArray();
|
||||||
getUsedFrames(sprites.Length);
|
GetUsedFrames(sprites.Length);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -449,7 +449,7 @@ namespace OpenRA.Mods.Common.Graphics
|
|||||||
if (filename == null)
|
if (filename == null)
|
||||||
throw new YamlException($"Sequence {image}.{sequence} does not define a filename.");
|
throw new YamlException($"Sequence {image}.{sequence} does not define a filename.");
|
||||||
|
|
||||||
sprites = cache[filename, getUsedFrames].Select(s =>
|
sprites = cache[filename, GetUsedFrames].Select(s =>
|
||||||
{
|
{
|
||||||
if (s == null)
|
if (s == null)
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -63,8 +63,8 @@ namespace OpenRA.Mods.Common.Installer
|
|||||||
{
|
{
|
||||||
Log.Write("install", $"Extracting {sourcePath} -> {targetPath}");
|
Log.Write("install", $"Extracting {sourcePath} -> {targetPath}");
|
||||||
var displayFilename = Path.GetFileName(Path.GetFileName(targetPath));
|
var displayFilename = Path.GetFileName(Path.GetFileName(targetPath));
|
||||||
Action<int> onProgress = percent => updateMessage(modData.Translation.GetString(InstallFromSourceLogic.ExtracingProgress, Translation.Arguments("filename", displayFilename, "progress", percent)));
|
void OnProgress(int percent) => updateMessage(modData.Translation.GetString(InstallFromSourceLogic.ExtracingProgress, Translation.Arguments("filename", displayFilename, "progress", percent)));
|
||||||
reader.ExtractFile(node.Value.Value, target, onProgress);
|
reader.ExtractFile(node.Value.Value, target, OnProgress);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,8 +44,8 @@ namespace OpenRA.Mods.Common.Installer
|
|||||||
{
|
{
|
||||||
Log.Write("install", $"Extracting {sourcePath} -> {targetPath}");
|
Log.Write("install", $"Extracting {sourcePath} -> {targetPath}");
|
||||||
var displayFilename = Path.GetFileName(Path.GetFileName(targetPath));
|
var displayFilename = Path.GetFileName(Path.GetFileName(targetPath));
|
||||||
Action<int> onProgress = percent => updateMessage(modData.Translation.GetString(InstallFromSourceLogic.ExtracingProgress, Translation.Arguments("filename", displayFilename, "progress", percent)));
|
void OnProgress(int percent) => updateMessage(modData.Translation.GetString(InstallFromSourceLogic.ExtracingProgress, Translation.Arguments("filename", displayFilename, "progress", percent)));
|
||||||
reader.ExtractFile(node.Value.Value, target, onProgress);
|
reader.ExtractFile(node.Value.Value, target, OnProgress);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ namespace OpenRA.Mods.Common.Scripting
|
|||||||
public void AfterDelay(int delay, LuaFunction func)
|
public void AfterDelay(int delay, LuaFunction func)
|
||||||
{
|
{
|
||||||
var f = (LuaFunction)func.CopyReference();
|
var f = (LuaFunction)func.CopyReference();
|
||||||
Action doCall = () =>
|
void DoCall()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -47,9 +47,9 @@ namespace OpenRA.Mods.Common.Scripting
|
|||||||
{
|
{
|
||||||
Context.FatalError(e.Message);
|
Context.FatalError(e.Message);
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
Context.World.AddFrameEndTask(w => w.Add(new DelayedAction(delay, doCall)));
|
Context.World.AddFrameEndTask(w => w.Add(new DelayedAction(delay, DoCall)));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Desc("Call a function for each passenger when it enters a transport. " +
|
[Desc("Call a function for each passenger when it enters a transport. " +
|
||||||
@@ -93,7 +93,7 @@ namespace OpenRA.Mods.Common.Scripting
|
|||||||
{
|
{
|
||||||
var group = actors.ToList();
|
var group = actors.ToList();
|
||||||
var f = (LuaFunction)func.CopyReference();
|
var f = (LuaFunction)func.CopyReference();
|
||||||
Action<Actor> onMemberKilled = m =>
|
void OnMemberKilled(Actor m)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -106,10 +106,10 @@ namespace OpenRA.Mods.Common.Scripting
|
|||||||
{
|
{
|
||||||
Context.FatalError(e.Message);
|
Context.FatalError(e.Message);
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
foreach (var a in group)
|
foreach (var a in group)
|
||||||
GetScriptTriggers(a).OnKilledInternal += onMemberKilled;
|
GetScriptTriggers(a).OnKilledInternal += OnMemberKilled;
|
||||||
}
|
}
|
||||||
|
|
||||||
[Desc("Call a function when one of the actors in a group is killed. The callback " +
|
[Desc("Call a function when one of the actors in a group is killed. The callback " +
|
||||||
@@ -118,7 +118,7 @@ namespace OpenRA.Mods.Common.Scripting
|
|||||||
{
|
{
|
||||||
var called = false;
|
var called = false;
|
||||||
var f = (LuaFunction)func.CopyReference();
|
var f = (LuaFunction)func.CopyReference();
|
||||||
Action<Actor> onMemberKilled = m =>
|
void OnMemberKilled(Actor m)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -135,10 +135,10 @@ namespace OpenRA.Mods.Common.Scripting
|
|||||||
{
|
{
|
||||||
Context.FatalError(e.Message);
|
Context.FatalError(e.Message);
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
foreach (var a in actors)
|
foreach (var a in actors)
|
||||||
GetScriptTriggers(a).OnKilledInternal += onMemberKilled;
|
GetScriptTriggers(a).OnKilledInternal += OnMemberKilled;
|
||||||
}
|
}
|
||||||
|
|
||||||
[Desc("Call a function when this actor produces another actor. " +
|
[Desc("Call a function when this actor produces another actor. " +
|
||||||
@@ -211,7 +211,7 @@ namespace OpenRA.Mods.Common.Scripting
|
|||||||
var group = actors.ToList();
|
var group = actors.ToList();
|
||||||
|
|
||||||
var f = (LuaFunction)func.CopyReference();
|
var f = (LuaFunction)func.CopyReference();
|
||||||
Action<Actor> onMemberRemoved = m =>
|
void OnMemberRemoved(Actor m)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -230,9 +230,9 @@ namespace OpenRA.Mods.Common.Scripting
|
|||||||
{
|
{
|
||||||
Context.FatalError(e.Message);
|
Context.FatalError(e.Message);
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
Action<Actor> onMemberAdded = m =>
|
void OnMemberAdded(Actor m)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -245,12 +245,12 @@ namespace OpenRA.Mods.Common.Scripting
|
|||||||
{
|
{
|
||||||
Context.FatalError(e.Message);
|
Context.FatalError(e.Message);
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
foreach (var a in group)
|
foreach (var a in group)
|
||||||
{
|
{
|
||||||
GetScriptTriggers(a).OnRemovedInternal += onMemberRemoved;
|
GetScriptTriggers(a).OnRemovedInternal += OnMemberRemoved;
|
||||||
GetScriptTriggers(a).OnAddedInternal += onMemberAdded;
|
GetScriptTriggers(a).OnAddedInternal += OnMemberAdded;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -268,7 +268,7 @@ namespace OpenRA.Mods.Common.Scripting
|
|||||||
var called = false;
|
var called = false;
|
||||||
|
|
||||||
var f = (LuaFunction)func.CopyReference();
|
var f = (LuaFunction)func.CopyReference();
|
||||||
Action<Actor> onKilledOrCaptured = m =>
|
void OnKilledOrCaptured(Actor m)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -284,10 +284,10 @@ namespace OpenRA.Mods.Common.Scripting
|
|||||||
{
|
{
|
||||||
Context.FatalError(e.Message);
|
Context.FatalError(e.Message);
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
GetScriptTriggers(a).OnCapturedInternal += onKilledOrCaptured;
|
GetScriptTriggers(a).OnCapturedInternal += OnKilledOrCaptured;
|
||||||
GetScriptTriggers(a).OnKilledInternal += onKilledOrCaptured;
|
GetScriptTriggers(a).OnKilledInternal += OnKilledOrCaptured;
|
||||||
}
|
}
|
||||||
|
|
||||||
[Desc("Call a function when all of the actors in a group have been killed or captured. " +
|
[Desc("Call a function when all of the actors in a group have been killed or captured. " +
|
||||||
@@ -297,7 +297,7 @@ namespace OpenRA.Mods.Common.Scripting
|
|||||||
var group = actors.ToList();
|
var group = actors.ToList();
|
||||||
|
|
||||||
var f = (LuaFunction)func.CopyReference();
|
var f = (LuaFunction)func.CopyReference();
|
||||||
Action<Actor> onMemberKilledOrCaptured = m =>
|
void OnMemberKilledOrCaptured(Actor m)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -312,12 +312,12 @@ namespace OpenRA.Mods.Common.Scripting
|
|||||||
{
|
{
|
||||||
Context.FatalError(e.Message);
|
Context.FatalError(e.Message);
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
foreach (var a in group)
|
foreach (var a in group)
|
||||||
{
|
{
|
||||||
GetScriptTriggers(a).OnCapturedInternal += onMemberKilledOrCaptured;
|
GetScriptTriggers(a).OnCapturedInternal += OnMemberKilledOrCaptured;
|
||||||
GetScriptTriggers(a).OnKilledInternal += onMemberKilledOrCaptured;
|
GetScriptTriggers(a).OnKilledInternal += OnMemberKilledOrCaptured;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -329,7 +329,7 @@ namespace OpenRA.Mods.Common.Scripting
|
|||||||
// We can't easily dispose onEntry, so we'll have to rely on finalization for it.
|
// We can't easily dispose onEntry, so we'll have to rely on finalization for it.
|
||||||
var onEntry = (LuaFunction)func.CopyReference();
|
var onEntry = (LuaFunction)func.CopyReference();
|
||||||
var triggerId = 0;
|
var triggerId = 0;
|
||||||
Action<Actor> invokeEntry = a =>
|
void InvokeEntry(Actor a)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -341,9 +341,9 @@ namespace OpenRA.Mods.Common.Scripting
|
|||||||
{
|
{
|
||||||
Context.FatalError(e.Message);
|
Context.FatalError(e.Message);
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
triggerId = Context.World.ActorMap.AddCellTrigger(cells, invokeEntry, null);
|
triggerId = Context.World.ActorMap.AddCellTrigger(cells, InvokeEntry, null);
|
||||||
|
|
||||||
return triggerId;
|
return triggerId;
|
||||||
}
|
}
|
||||||
@@ -356,7 +356,7 @@ namespace OpenRA.Mods.Common.Scripting
|
|||||||
// We can't easily dispose onExit, so we'll have to rely on finalization for it.
|
// We can't easily dispose onExit, so we'll have to rely on finalization for it.
|
||||||
var onExit = (LuaFunction)func.CopyReference();
|
var onExit = (LuaFunction)func.CopyReference();
|
||||||
var triggerId = 0;
|
var triggerId = 0;
|
||||||
Action<Actor> invokeExit = a =>
|
void InvokeExit(Actor a)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -368,9 +368,9 @@ namespace OpenRA.Mods.Common.Scripting
|
|||||||
{
|
{
|
||||||
Context.FatalError(e.Message);
|
Context.FatalError(e.Message);
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
triggerId = Context.World.ActorMap.AddCellTrigger(cells, null, invokeExit);
|
triggerId = Context.World.ActorMap.AddCellTrigger(cells, null, InvokeExit);
|
||||||
|
|
||||||
return triggerId;
|
return triggerId;
|
||||||
}
|
}
|
||||||
@@ -389,7 +389,7 @@ namespace OpenRA.Mods.Common.Scripting
|
|||||||
// We can't easily dispose onEntry, so we'll have to rely on finalization for it.
|
// We can't easily dispose onEntry, so we'll have to rely on finalization for it.
|
||||||
var onEntry = (LuaFunction)func.CopyReference();
|
var onEntry = (LuaFunction)func.CopyReference();
|
||||||
var triggerId = 0;
|
var triggerId = 0;
|
||||||
Action<Actor> invokeEntry = a =>
|
void InvokeEntry(Actor a)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -401,9 +401,9 @@ namespace OpenRA.Mods.Common.Scripting
|
|||||||
{
|
{
|
||||||
Context.FatalError(e.Message);
|
Context.FatalError(e.Message);
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
triggerId = Context.World.ActorMap.AddProximityTrigger(pos, range, WDist.Zero, invokeEntry, null);
|
triggerId = Context.World.ActorMap.AddProximityTrigger(pos, range, WDist.Zero, InvokeEntry, null);
|
||||||
|
|
||||||
return triggerId;
|
return triggerId;
|
||||||
}
|
}
|
||||||
@@ -416,7 +416,7 @@ namespace OpenRA.Mods.Common.Scripting
|
|||||||
// We can't easily dispose onExit, so we'll have to rely on finalization for it.
|
// We can't easily dispose onExit, so we'll have to rely on finalization for it.
|
||||||
var onExit = (LuaFunction)func.CopyReference();
|
var onExit = (LuaFunction)func.CopyReference();
|
||||||
var triggerId = 0;
|
var triggerId = 0;
|
||||||
Action<Actor> invokeExit = a =>
|
void InvokeExit(Actor a)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -428,9 +428,9 @@ namespace OpenRA.Mods.Common.Scripting
|
|||||||
{
|
{
|
||||||
Context.FatalError(e.Message);
|
Context.FatalError(e.Message);
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
triggerId = Context.World.ActorMap.AddProximityTrigger(pos, range, WDist.Zero, null, invokeExit);
|
triggerId = Context.World.ActorMap.AddProximityTrigger(pos, range, WDist.Zero, null, InvokeExit);
|
||||||
|
|
||||||
return triggerId;
|
return triggerId;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -218,7 +218,7 @@ namespace OpenRA.Mods.Common.Scripting
|
|||||||
foreach (var q in player.PlayerActor.TraitsImplementing<ClassicProductionQueue>().Where(q => q.Enabled))
|
foreach (var q in player.PlayerActor.TraitsImplementing<ClassicProductionQueue>().Where(q => q.Enabled))
|
||||||
queues.Add(q.Info.Type, q);
|
queues.Add(q.Info.Type, q);
|
||||||
|
|
||||||
Action<Actor, Actor> globalProductionHandler = (factory, unit) =>
|
void GlobalProductionHandler(Actor factory, Actor unit)
|
||||||
{
|
{
|
||||||
if (factory.Owner != player)
|
if (factory.Owner != player)
|
||||||
return;
|
return;
|
||||||
@@ -227,10 +227,10 @@ namespace OpenRA.Mods.Common.Scripting
|
|||||||
|
|
||||||
if (productionHandlers.ContainsKey(queue))
|
if (productionHandlers.ContainsKey(queue))
|
||||||
productionHandlers[queue](factory, unit);
|
productionHandlers[queue](factory, unit);
|
||||||
};
|
}
|
||||||
|
|
||||||
var triggers = TriggerGlobal.GetScriptTriggers(player.PlayerActor);
|
var triggers = TriggerGlobal.GetScriptTriggers(player.PlayerActor);
|
||||||
triggers.OnOtherProducedInternal += globalProductionHandler;
|
triggers.OnOtherProducedInternal += GlobalProductionHandler;
|
||||||
}
|
}
|
||||||
|
|
||||||
[Desc("Build the specified set of actors using classic (RA-style) production queues. " +
|
[Desc("Build the specified set of actors using classic (RA-style) production queues. " +
|
||||||
@@ -259,7 +259,7 @@ namespace OpenRA.Mods.Common.Scripting
|
|||||||
var squad = new List<Actor>();
|
var squad = new List<Actor>();
|
||||||
var func = actionFunc.CopyReference() as LuaFunction;
|
var func = actionFunc.CopyReference() as LuaFunction;
|
||||||
|
|
||||||
Action<Actor, Actor> productionHandler = (factory, unit) =>
|
void ProductionHandler(Actor factory, Actor unit)
|
||||||
{
|
{
|
||||||
squad.Add(unit);
|
squad.Add(unit);
|
||||||
if (squad.Count >= squadSize)
|
if (squad.Count >= squadSize)
|
||||||
@@ -271,10 +271,10 @@ namespace OpenRA.Mods.Common.Scripting
|
|||||||
foreach (var q in queueTypes)
|
foreach (var q in queueTypes)
|
||||||
productionHandlers.Remove(q);
|
productionHandlers.Remove(q);
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
foreach (var q in queueTypes)
|
foreach (var q in queueTypes)
|
||||||
productionHandlers.Add(q, productionHandler);
|
productionHandlers.Add(q, ProductionHandler);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var actorType in actorTypes)
|
foreach (var actorType in actorTypes)
|
||||||
|
|||||||
@@ -560,7 +560,7 @@ namespace OpenRA.Mods.Common.Server
|
|||||||
}
|
}
|
||||||
|
|
||||||
var lastMap = server.LobbyInfo.GlobalSettings.Map;
|
var lastMap = server.LobbyInfo.GlobalSettings.Map;
|
||||||
Action<MapPreview> selectMap = map =>
|
void SelectMap(MapPreview map)
|
||||||
{
|
{
|
||||||
lock (server.LobbyInfo)
|
lock (server.LobbyInfo)
|
||||||
{
|
{
|
||||||
@@ -646,28 +646,28 @@ namespace OpenRA.Mods.Common.Server
|
|||||||
if (briefing != null)
|
if (briefing != null)
|
||||||
server.SendMessage(briefing);
|
server.SendMessage(briefing);
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
Action queryFailed = () => server.SendLocalizedMessageTo(conn, UnknownMap);
|
void QueryFailed() => server.SendLocalizedMessageTo(conn, UnknownMap);
|
||||||
|
|
||||||
var m = server.ModData.MapCache[s];
|
var m = server.ModData.MapCache[s];
|
||||||
if (m.Status == MapStatus.Available || m.Status == MapStatus.DownloadAvailable)
|
if (m.Status == MapStatus.Available || m.Status == MapStatus.DownloadAvailable)
|
||||||
selectMap(m);
|
SelectMap(m);
|
||||||
else if (server.Settings.QueryMapRepository)
|
else if (server.Settings.QueryMapRepository)
|
||||||
{
|
{
|
||||||
server.SendLocalizedMessageTo(conn, SearchingMap);
|
server.SendLocalizedMessageTo(conn, SearchingMap);
|
||||||
var mapRepository = server.ModData.Manifest.Get<WebServices>().MapRepository;
|
var mapRepository = server.ModData.Manifest.Get<WebServices>().MapRepository;
|
||||||
var reported = false;
|
var reported = false;
|
||||||
server.ModData.MapCache.QueryRemoteMapDetails(mapRepository, new[] { s }, selectMap, _ =>
|
server.ModData.MapCache.QueryRemoteMapDetails(mapRepository, new[] { s }, SelectMap, _ =>
|
||||||
{
|
{
|
||||||
if (!reported)
|
if (!reported)
|
||||||
queryFailed();
|
QueryFailed();
|
||||||
|
|
||||||
reported = true;
|
reported = true;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
queryFailed();
|
QueryFailed();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -1232,17 +1232,17 @@ namespace OpenRA.Mods.Common.Server
|
|||||||
var colorManager = server.ModData.DefaultRules.Actors[SystemActors.World].TraitInfo<ColorPickerManagerInfo>();
|
var colorManager = server.ModData.DefaultRules.Actors[SystemActors.World].TraitInfo<ColorPickerManagerInfo>();
|
||||||
var askColor = askedColor;
|
var askColor = askedColor;
|
||||||
|
|
||||||
Action<string> onError = message =>
|
void OnError(string message)
|
||||||
{
|
{
|
||||||
if (connectionToEcho != null && message != null)
|
if (connectionToEcho != null && message != null)
|
||||||
server.SendLocalizedMessageTo(connectionToEcho, message);
|
server.SendLocalizedMessageTo(connectionToEcho, message);
|
||||||
};
|
}
|
||||||
|
|
||||||
var terrainColors = server.ModData.DefaultTerrainInfo[server.Map.TileSet].RestrictedPlayerColors;
|
var terrainColors = server.ModData.DefaultTerrainInfo[server.Map.TileSet].RestrictedPlayerColors;
|
||||||
var playerColors = server.LobbyInfo.Clients.Where(c => c.Index != playerIndex).Select(c => c.Color)
|
var playerColors = server.LobbyInfo.Clients.Where(c => c.Index != playerIndex).Select(c => c.Color)
|
||||||
.Concat(server.Map.Players.Players.Values.Select(p => p.Color)).ToList();
|
.Concat(server.Map.Players.Players.Values.Select(p => p.Color)).ToList();
|
||||||
|
|
||||||
return colorManager.MakeValid(askColor, server.Random, terrainColors, playerColors, onError);
|
return colorManager.MakeValid(askColor, server.Random, terrainColors, playerColors, OnError);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -280,11 +280,11 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
foreach (var na in notifyAttacks)
|
foreach (var na in notifyAttacks)
|
||||||
na.PreparingAttack(self, target, this, barrel);
|
na.PreparingAttack(self, target, this, barrel);
|
||||||
|
|
||||||
Func<WPos> muzzlePosition = () => self.CenterPosition + MuzzleOffset(self, barrel);
|
WPos MuzzlePosition() => self.CenterPosition + MuzzleOffset(self, barrel);
|
||||||
Func<WAngle> muzzleFacing = () => MuzzleOrientation(self, barrel).Yaw;
|
WAngle MuzzleFacing() => MuzzleOrientation(self, barrel).Yaw;
|
||||||
var muzzleOrientation = WRot.FromYaw(muzzleFacing());
|
var muzzleOrientation = WRot.FromYaw(MuzzleFacing());
|
||||||
|
|
||||||
var passiveTarget = Weapon.TargetActorCenter ? target.CenterPosition : target.Positions.PositionClosestTo(muzzlePosition());
|
var passiveTarget = Weapon.TargetActorCenter ? target.CenterPosition : target.Positions.PositionClosestTo(MuzzlePosition());
|
||||||
var initialOffset = Weapon.FirstBurstTargetOffset;
|
var initialOffset = Weapon.FirstBurstTargetOffset;
|
||||||
if (initialOffset != WVec.Zero)
|
if (initialOffset != WVec.Zero)
|
||||||
{
|
{
|
||||||
@@ -304,8 +304,8 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
var args = new ProjectileArgs
|
var args = new ProjectileArgs
|
||||||
{
|
{
|
||||||
Weapon = Weapon,
|
Weapon = Weapon,
|
||||||
Facing = muzzleFacing(),
|
Facing = MuzzleFacing(),
|
||||||
CurrentMuzzleFacing = muzzleFacing,
|
CurrentMuzzleFacing = MuzzleFacing,
|
||||||
|
|
||||||
DamageModifiers = damageModifiers.ToArray(),
|
DamageModifiers = damageModifiers.ToArray(),
|
||||||
|
|
||||||
@@ -313,8 +313,8 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
RangeModifiers = rangeModifiers.ToArray(),
|
RangeModifiers = rangeModifiers.ToArray(),
|
||||||
|
|
||||||
Source = muzzlePosition(),
|
Source = MuzzlePosition(),
|
||||||
CurrentSource = muzzlePosition,
|
CurrentSource = MuzzlePosition,
|
||||||
SourceActor = self,
|
SourceActor = self,
|
||||||
PassiveTarget = passiveTarget,
|
PassiveTarget = passiveTarget,
|
||||||
GuidedTarget = target
|
GuidedTarget = target
|
||||||
|
|||||||
@@ -390,7 +390,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
return (null, 0);
|
return (null, 0);
|
||||||
|
|
||||||
// Find the buildable cell that is closest to pos and centered around center
|
// Find the buildable cell that is closest to pos and centered around center
|
||||||
Func<CPos, CPos, int, int, (CPos? Location, int Variant)> findPos = (center, target, minRange, maxRange) =>
|
(CPos? Location, int Variant) FindPos(CPos center, CPos target, int minRange, int maxRange)
|
||||||
{
|
{
|
||||||
var actorVariant = 0;
|
var actorVariant = 0;
|
||||||
var buildingVariantInfo = actorInfo.TraitInfoOrDefault<PlaceBuildingVariantsInfo>();
|
var buildingVariantInfo = actorInfo.TraitInfoOrDefault<PlaceBuildingVariantsInfo>();
|
||||||
@@ -461,7 +461,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (null, 0);
|
return (null, 0);
|
||||||
};
|
}
|
||||||
|
|
||||||
var baseCenter = baseBuilder.GetRandomBaseCenter();
|
var baseCenter = baseBuilder.GetRandomBaseCenter();
|
||||||
|
|
||||||
@@ -475,7 +475,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
var targetCell = closestEnemy != null ? closestEnemy.Location : baseCenter;
|
var targetCell = closestEnemy != null ? closestEnemy.Location : baseCenter;
|
||||||
|
|
||||||
return findPos(baseBuilder.DefenseCenter, targetCell, baseBuilder.Info.MinimumDefenseRadius, baseBuilder.Info.MaximumDefenseRadius);
|
return FindPos(baseBuilder.DefenseCenter, targetCell, baseBuilder.Info.MinimumDefenseRadius, baseBuilder.Info.MaximumDefenseRadius);
|
||||||
|
|
||||||
case BuildingType.Refinery:
|
case BuildingType.Refinery:
|
||||||
|
|
||||||
@@ -488,17 +488,17 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
foreach (var r in nearbyResources)
|
foreach (var r in nearbyResources)
|
||||||
{
|
{
|
||||||
var found = findPos(baseCenter, r, baseBuilder.Info.MinBaseRadius, baseBuilder.Info.MaxBaseRadius);
|
var found = FindPos(baseCenter, r, baseBuilder.Info.MinBaseRadius, baseBuilder.Info.MaxBaseRadius);
|
||||||
if (found.Location != null)
|
if (found.Location != null)
|
||||||
return found;
|
return found;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Try and find a free spot somewhere else in the base
|
// Try and find a free spot somewhere else in the base
|
||||||
return findPos(baseCenter, baseCenter, baseBuilder.Info.MinBaseRadius, baseBuilder.Info.MaxBaseRadius);
|
return FindPos(baseCenter, baseCenter, baseBuilder.Info.MinBaseRadius, baseBuilder.Info.MaxBaseRadius);
|
||||||
|
|
||||||
case BuildingType.Building:
|
case BuildingType.Building:
|
||||||
return findPos(baseCenter, baseCenter, baseBuilder.Info.MinBaseRadius,
|
return FindPos(baseCenter, baseCenter, baseBuilder.Info.MinBaseRadius,
|
||||||
distanceToBaseIsImportant ? baseBuilder.Info.MaxBaseRadius : world.Map.Grid.MaximumTileSearchRange);
|
distanceToBaseIsImportant ? baseBuilder.Info.MaxBaseRadius : world.Map.Grid.MaximumTileSearchRange);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -138,12 +138,12 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
Target FindNextResource(Actor actor, HarvesterTraitWrapper harv)
|
Target FindNextResource(Actor actor, HarvesterTraitWrapper harv)
|
||||||
{
|
{
|
||||||
Func<CPos, bool> isValidResource = cell =>
|
bool IsValidResource(CPos cell) =>
|
||||||
harv.Harvester.CanHarvestCell(cell) &&
|
harv.Harvester.CanHarvestCell(cell) &&
|
||||||
claimLayer.CanClaimCell(actor, cell);
|
claimLayer.CanClaimCell(actor, cell);
|
||||||
|
|
||||||
var path = harv.Mobile.PathFinder.FindPathToTargetCellByPredicate(
|
var path = harv.Mobile.PathFinder.FindPathToTargetCellByPredicate(
|
||||||
actor, new[] { actor.Location }, isValidResource, BlockedByActor.Stationary,
|
actor, new[] { actor.Location }, IsValidResource, BlockedByActor.Stationary,
|
||||||
loc => world.FindActorsInCircle(world.Map.CenterOfCell(loc), Info.HarvesterEnemyAvoidanceRadius)
|
loc => world.FindActorsInCircle(world.Map.CenterOfCell(loc), Info.HarvesterEnemyAvoidanceRadius)
|
||||||
.Where(u => !u.IsDead && actor.Owner.RelationshipWith(u.Owner) == PlayerRelationship.Enemy)
|
.Where(u => !u.IsDead && actor.Owner.RelationshipWith(u.Owner) == PlayerRelationship.Enemy)
|
||||||
.Sum(u => Math.Max(WDist.Zero.Length, Info.HarvesterEnemyAvoidanceRadius.Length - (world.Map.CenterOfCell(loc) - u.CenterPosition).Length)));
|
.Sum(u => Math.Max(WDist.Zero.Length, Info.HarvesterEnemyAvoidanceRadius.Length - (world.Map.CenterOfCell(loc) - u.CenterPosition).Length)));
|
||||||
|
|||||||
@@ -9,7 +9,6 @@
|
|||||||
*/
|
*/
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using OpenRA.Traits;
|
using OpenRA.Traits;
|
||||||
@@ -178,7 +177,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
return null;
|
return null;
|
||||||
|
|
||||||
// Find the buildable cell that is closest to pos and centered around center
|
// Find the buildable cell that is closest to pos and centered around center
|
||||||
Func<CPos, CPos, int, int, CPos?> findPos = (center, target, minRange, maxRange) =>
|
CPos? FindPos(CPos center, CPos target, int minRange, int maxRange)
|
||||||
{
|
{
|
||||||
var cells = world.Map.FindTilesInAnnulus(center, minRange, maxRange);
|
var cells = world.Map.FindTilesInAnnulus(center, minRange, maxRange);
|
||||||
|
|
||||||
@@ -193,11 +192,11 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
return cell;
|
return cell;
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
};
|
}
|
||||||
|
|
||||||
var baseCenter = GetRandomBaseCenter();
|
var baseCenter = GetRandomBaseCenter();
|
||||||
|
|
||||||
return findPos(baseCenter, baseCenter, Info.MinBaseRadius,
|
return FindPos(baseCenter, baseCenter, Info.MinBaseRadius,
|
||||||
distanceToBaseIsImportant ? Info.MaxBaseRadius : world.Map.Grid.MaximumTileSearchRange);
|
distanceToBaseIsImportant ? Info.MaxBaseRadius : world.Map.Grid.MaximumTileSearchRange);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -74,15 +74,15 @@ namespace OpenRA.Mods.Common.Traits.Render
|
|||||||
anim.PlayRepeating(RenderSprites.NormalizeSequence(anim, init.GetDamageState(), Sequence));
|
anim.PlayRepeating(RenderSprites.NormalizeSequence(anim, init.GetDamageState(), Sequence));
|
||||||
|
|
||||||
var body = init.Actor.TraitInfo<BodyOrientationInfo>();
|
var body = init.Actor.TraitInfo<BodyOrientationInfo>();
|
||||||
Func<WRot> orientation = () => body.QuantizeOrientation(WRot.FromYaw(facing()), facings);
|
WRot Orientation() => body.QuantizeOrientation(WRot.FromYaw(facing()), facings);
|
||||||
Func<WVec> offset = () => body.LocalToWorld(Offset.Rotate(orientation()));
|
WVec Offset() => body.LocalToWorld(this.Offset.Rotate(Orientation()));
|
||||||
Func<int> zOffset = () =>
|
int ZOffset()
|
||||||
{
|
{
|
||||||
var tmpOffset = offset();
|
var tmpOffset = Offset();
|
||||||
return tmpOffset.Y + tmpOffset.Z + 1;
|
return tmpOffset.Y + tmpOffset.Z + 1;
|
||||||
};
|
}
|
||||||
|
|
||||||
yield return new SpriteActorPreview(anim, offset, zOffset, p);
|
yield return new SpriteActorPreview(anim, Offset, ZOffset, p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -90,15 +90,15 @@ namespace OpenRA.Mods.Common.Traits.Render
|
|||||||
anim.PlayThen(OpeningSequence, () => anim.PlayRepeating(Sequence));
|
anim.PlayThen(OpeningSequence, () => anim.PlayRepeating(Sequence));
|
||||||
|
|
||||||
var body = init.Actor.TraitInfo<BodyOrientationInfo>();
|
var body = init.Actor.TraitInfo<BodyOrientationInfo>();
|
||||||
Func<WRot> orientation = () => body.QuantizeOrientation(WRot.FromYaw(facing()), facings);
|
WRot Orientation() => body.QuantizeOrientation(WRot.FromYaw(facing()), facings);
|
||||||
Func<WVec> offset = () => body.LocalToWorld(Offset.Rotate(orientation()));
|
WVec Offset() => body.LocalToWorld(this.Offset.Rotate(Orientation()));
|
||||||
Func<int> zOffset = () =>
|
int ZOffset()
|
||||||
{
|
{
|
||||||
var tmpOffset = offset();
|
var tmpOffset = Offset();
|
||||||
return tmpOffset.Y + tmpOffset.Z + 1;
|
return tmpOffset.Y + tmpOffset.Z + 1;
|
||||||
};
|
}
|
||||||
|
|
||||||
yield return new SpriteActorPreview(anim, offset, zOffset, p);
|
yield return new SpriteActorPreview(anim, Offset, ZOffset, p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,6 @@
|
|||||||
*/
|
*/
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using OpenRA.Graphics;
|
using OpenRA.Graphics;
|
||||||
@@ -50,15 +49,15 @@ namespace OpenRA.Mods.Common.Traits.Render
|
|||||||
anim.Play(RenderSprites.NormalizeSequence(anim, init.GetDamageState(), Sequence));
|
anim.Play(RenderSprites.NormalizeSequence(anim, init.GetDamageState(), Sequence));
|
||||||
|
|
||||||
var facing = init.GetFacing();
|
var facing = init.GetFacing();
|
||||||
Func<WRot> orientation = () => body.QuantizeOrientation(WRot.FromYaw(facing()), facings);
|
WRot Orientation() => body.QuantizeOrientation(WRot.FromYaw(facing()), facings);
|
||||||
Func<WVec> turretOffset = () => body.LocalToWorld(t.Offset.Rotate(orientation()));
|
WVec TurretOffset() => body.LocalToWorld(t.Offset.Rotate(Orientation()));
|
||||||
Func<int> zOffset = () =>
|
int ZOffset()
|
||||||
{
|
{
|
||||||
var tmpOffset = turretOffset();
|
var tmpOffset = TurretOffset();
|
||||||
return -(tmpOffset.Y + tmpOffset.Z) + 1;
|
return -(tmpOffset.Y + tmpOffset.Z) + 1;
|
||||||
};
|
}
|
||||||
|
|
||||||
yield return new SpriteActorPreview(anim, turretOffset, zOffset, p);
|
yield return new SpriteActorPreview(anim, TurretOffset, ZOffset, p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -75,18 +75,18 @@ namespace OpenRA.Mods.Common.Traits.Render
|
|||||||
{
|
{
|
||||||
rs = init.Self.Trait<RenderSprites>();
|
rs = init.Self.Trait<RenderSprites>();
|
||||||
|
|
||||||
Func<bool> paused = () => IsTraitPaused &&
|
bool Paused() => IsTraitPaused &&
|
||||||
DefaultAnimation.CurrentSequence.Name == NormalizeSequence(init.Self, Info.Sequence);
|
DefaultAnimation.CurrentSequence.Name == NormalizeSequence(init.Self, Info.Sequence);
|
||||||
|
|
||||||
Func<WVec> subtractDAT = null;
|
Func<WVec> subtractDAT = null;
|
||||||
if (info.ForceToGround)
|
if (info.ForceToGround)
|
||||||
subtractDAT = () => new WVec(0, 0, -init.Self.World.Map.DistanceAboveTerrain(init.Self.CenterPosition).Length);
|
subtractDAT = () => new WVec(0, 0, -init.Self.World.Map.DistanceAboveTerrain(init.Self.CenterPosition).Length);
|
||||||
|
|
||||||
DefaultAnimation = new Animation(init.World, rs.GetImage(init.Self), baseFacing, paused);
|
DefaultAnimation = new Animation(init.World, rs.GetImage(init.Self), baseFacing, Paused);
|
||||||
rs.Add(new AnimationWithOffset(DefaultAnimation, subtractDAT, () => IsTraitDisabled), info.Palette, info.IsPlayerPalette);
|
rs.Add(new AnimationWithOffset(DefaultAnimation, subtractDAT, () => IsTraitDisabled), info.Palette, info.IsPlayerPalette);
|
||||||
|
|
||||||
// Cache the bounds from the default sequence to avoid flickering when the animation changes
|
// Cache the bounds from the default sequence to avoid flickering when the animation changes
|
||||||
boundsAnimation = new Animation(init.World, rs.GetImage(init.Self), baseFacing, paused);
|
boundsAnimation = new Animation(init.World, rs.GetImage(init.Self), baseFacing, Paused);
|
||||||
boundsAnimation.PlayRepeating(info.Sequence);
|
boundsAnimation.PlayRepeating(info.Sequence);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -55,20 +55,20 @@ namespace OpenRA.Mods.Common.Traits.Render
|
|||||||
anim.Play(RenderSprites.NormalizeSequence(anim, init.GetDamageState(), Sequence));
|
anim.Play(RenderSprites.NormalizeSequence(anim, init.GetDamageState(), Sequence));
|
||||||
|
|
||||||
var facing = init.GetFacing();
|
var facing = init.GetFacing();
|
||||||
Func<WRot> orientation = () => body.QuantizeOrientation(WRot.FromYaw(facing()), facings);
|
WRot Orientation() => body.QuantizeOrientation(WRot.FromYaw(facing()), facings);
|
||||||
Func<WVec> offset = () => body.LocalToWorld(t.Offset.Rotate(orientation()));
|
WVec Offset() => body.LocalToWorld(t.Offset.Rotate(Orientation()));
|
||||||
Func<int> zOffset = () =>
|
int ZOffset()
|
||||||
{
|
{
|
||||||
var tmpOffset = offset();
|
var tmpOffset = Offset();
|
||||||
return -(tmpOffset.Y + tmpOffset.Z) + 1;
|
return -(tmpOffset.Y + tmpOffset.Z) + 1;
|
||||||
};
|
}
|
||||||
|
|
||||||
if (IsPlayerPalette)
|
if (IsPlayerPalette)
|
||||||
p = init.WorldRenderer.Palette(Palette + init.Get<OwnerInit>().InternalName);
|
p = init.WorldRenderer.Palette(Palette + init.Get<OwnerInit>().InternalName);
|
||||||
else if (Palette != null)
|
else if (Palette != null)
|
||||||
p = init.WorldRenderer.Palette(Palette);
|
p = init.WorldRenderer.Palette(Palette);
|
||||||
|
|
||||||
yield return new SpriteActorPreview(anim, offset, zOffset, p);
|
yield return new SpriteActorPreview(anim, Offset, ZOffset, p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -52,10 +52,10 @@ namespace OpenRA.Mods.Common.Traits.Render
|
|||||||
var model = init.World.ModelCache.GetModelSequence(image, Sequence);
|
var model = init.World.ModelCache.GetModelSequence(image, Sequence);
|
||||||
|
|
||||||
var turretOrientation = t.PreviewOrientation(init, orientation, facings);
|
var turretOrientation = t.PreviewOrientation(init, orientation, facings);
|
||||||
Func<WVec> barrelOffset = () => body.LocalToWorld(t.Offset + LocalOffset.Rotate(turretOrientation()));
|
WVec BarrelOffset() => body.LocalToWorld(t.Offset + LocalOffset.Rotate(turretOrientation()));
|
||||||
Func<WRot> barrelOrientation = () => LocalOrientation.Rotate(turretOrientation());
|
WRot BarrelOrientation() => LocalOrientation.Rotate(turretOrientation());
|
||||||
|
|
||||||
yield return new ModelAnimation(model, barrelOffset, barrelOrientation, () => false, () => 0, ShowShadow);
|
yield return new ModelAnimation(model, BarrelOffset, BarrelOrientation, () => false, () => 0, ShowShadow);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
Beacon beacon = null;
|
Beacon beacon = null;
|
||||||
var aircraftInRange = new Dictionary<Actor, bool>();
|
var aircraftInRange = new Dictionary<Actor, bool>();
|
||||||
|
|
||||||
Action<Actor> onEnterRange = a =>
|
void OnEnterRange(Actor a)
|
||||||
{
|
{
|
||||||
// Spawn a camera and remove the beacon when the first plane enters the target area
|
// Spawn a camera and remove the beacon when the first plane enters the target area
|
||||||
if (info.CameraActor != null && camera == null && !aircraftInRange.Any(kv => kv.Value))
|
if (info.CameraActor != null && camera == null && !aircraftInRange.Any(kv => kv.Value))
|
||||||
@@ -112,18 +112,18 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
RemoveBeacon(beacon);
|
RemoveBeacon(beacon);
|
||||||
|
|
||||||
aircraftInRange[a] = true;
|
aircraftInRange[a] = true;
|
||||||
};
|
}
|
||||||
|
|
||||||
Action<Actor> onExitRange = a =>
|
void OnExitRange(Actor a)
|
||||||
{
|
{
|
||||||
aircraftInRange[a] = false;
|
aircraftInRange[a] = false;
|
||||||
|
|
||||||
// Remove the camera when the final plane leaves the target area
|
// Remove the camera when the final plane leaves the target area
|
||||||
if (!aircraftInRange.Any(kv => kv.Value))
|
if (!aircraftInRange.Any(kv => kv.Value))
|
||||||
RemoveCamera(camera);
|
RemoveCamera(camera);
|
||||||
};
|
}
|
||||||
|
|
||||||
Action<Actor> onRemovedFromWorld = a =>
|
void OnRemovedFromWorld(Actor a)
|
||||||
{
|
{
|
||||||
aircraftInRange[a] = false;
|
aircraftInRange[a] = false;
|
||||||
|
|
||||||
@@ -135,7 +135,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
RemoveCamera(camera);
|
RemoveCamera(camera);
|
||||||
RemoveBeacon(beacon);
|
RemoveBeacon(beacon);
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
// Create the actors immediately so they can be returned
|
// Create the actors immediately so they can be returned
|
||||||
for (var i = -info.SquadSize / 2; i <= info.SquadSize / 2; i++)
|
for (var i = -info.SquadSize / 2; i <= info.SquadSize / 2; i++)
|
||||||
@@ -160,9 +160,9 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
var attack = a.Trait<AttackBomber>();
|
var attack = a.Trait<AttackBomber>();
|
||||||
attack.SetTarget(target + targetOffset);
|
attack.SetTarget(target + targetOffset);
|
||||||
attack.OnEnteredAttackRange += onEnterRange;
|
attack.OnEnteredAttackRange += OnEnterRange;
|
||||||
attack.OnExitedAttackRange += onExitRange;
|
attack.OnExitedAttackRange += OnExitRange;
|
||||||
attack.OnRemovedFromWorld += onRemovedFromWorld;
|
attack.OnRemovedFromWorld += OnRemovedFromWorld;
|
||||||
}
|
}
|
||||||
|
|
||||||
self.World.AddFrameEndTask(w =>
|
self.World.AddFrameEndTask(w =>
|
||||||
|
|||||||
@@ -119,7 +119,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
Beacon beacon = null;
|
Beacon beacon = null;
|
||||||
var aircraftInRange = new Dictionary<Actor, bool>();
|
var aircraftInRange = new Dictionary<Actor, bool>();
|
||||||
|
|
||||||
Action<Actor> onEnterRange = a =>
|
void OnEnterRange(Actor a)
|
||||||
{
|
{
|
||||||
// Spawn a camera and remove the beacon when the first plane enters the target area
|
// Spawn a camera and remove the beacon when the first plane enters the target area
|
||||||
if (info.CameraActor != null && camera == null && !aircraftInRange.Any(kv => kv.Value))
|
if (info.CameraActor != null && camera == null && !aircraftInRange.Any(kv => kv.Value))
|
||||||
@@ -145,18 +145,18 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
}
|
}
|
||||||
|
|
||||||
aircraftInRange[a] = true;
|
aircraftInRange[a] = true;
|
||||||
};
|
}
|
||||||
|
|
||||||
Action<Actor> onExitRange = a =>
|
void OnExitRange(Actor a)
|
||||||
{
|
{
|
||||||
aircraftInRange[a] = false;
|
aircraftInRange[a] = false;
|
||||||
|
|
||||||
// Remove the camera when the final plane leaves the target area
|
// Remove the camera when the final plane leaves the target area
|
||||||
if (!aircraftInRange.Any(kv => kv.Value))
|
if (!aircraftInRange.Any(kv => kv.Value))
|
||||||
RemoveCamera(camera);
|
RemoveCamera(camera);
|
||||||
};
|
}
|
||||||
|
|
||||||
Action<Actor> onRemovedFromWorld = a =>
|
void OnRemovedFromWorld(Actor a)
|
||||||
{
|
{
|
||||||
aircraftInRange[a] = false;
|
aircraftInRange[a] = false;
|
||||||
|
|
||||||
@@ -168,7 +168,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
RemoveCamera(camera);
|
RemoveCamera(camera);
|
||||||
RemoveBeacon(beacon);
|
RemoveBeacon(beacon);
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
// Create the actors immediately so they can be returned
|
// Create the actors immediately so they can be returned
|
||||||
for (var i = -info.SquadSize / 2; i <= info.SquadSize / 2; i++)
|
for (var i = -info.SquadSize / 2; i <= info.SquadSize / 2; i++)
|
||||||
@@ -221,9 +221,9 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
var drop = a.Trait<ParaDrop>();
|
var drop = a.Trait<ParaDrop>();
|
||||||
drop.SetLZ(w.Map.CellContaining(target + targetOffset), !info.AllowImpassableCells);
|
drop.SetLZ(w.Map.CellContaining(target + targetOffset), !info.AllowImpassableCells);
|
||||||
drop.OnEnteredDropRange += onEnterRange;
|
drop.OnEnteredDropRange += OnEnterRange;
|
||||||
drop.OnExitedDropRange += onExitRange;
|
drop.OnExitedDropRange += OnExitRange;
|
||||||
drop.OnRemovedFromWorld += onRemovedFromWorld;
|
drop.OnRemovedFromWorld += OnRemovedFromWorld;
|
||||||
|
|
||||||
var cargo = a.Trait<Cargo>();
|
var cargo = a.Trait<Cargo>();
|
||||||
foreach (var unit in units.Skip(added).Take(passengersPerPlane))
|
foreach (var unit in units.Skip(added).Take(passengersPerPlane))
|
||||||
|
|||||||
@@ -115,13 +115,13 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
var body = init.Actor.TraitInfo<BodyOrientationInfo>();
|
var body = init.Actor.TraitInfo<BodyOrientationInfo>();
|
||||||
var turretFacing = LocalFacingFromInit(init);
|
var turretFacing = LocalFacingFromInit(init);
|
||||||
|
|
||||||
Func<WRot> world = () => WRot.FromYaw(turretFacing()).Rotate(orientation());
|
WRot World() => WRot.FromYaw(turretFacing()).Rotate(orientation());
|
||||||
if (facings == 0)
|
if (facings == 0)
|
||||||
return world;
|
return World;
|
||||||
|
|
||||||
// Quantize orientation to match a rendered sprite
|
// Quantize orientation to match a rendered sprite
|
||||||
// Implies no pitch or roll
|
// Implies no pitch or roll
|
||||||
return () => WRot.FromYaw(body.QuantizeFacing(world().Yaw, facings));
|
return () => WRot.FromYaw(body.QuantizeFacing(World().Yaw, facings));
|
||||||
}
|
}
|
||||||
|
|
||||||
public override object Create(ActorInitializer init) { return new Turreted(init, this); }
|
public override object Create(ActorInitializer init) { return new Turreted(init, this); }
|
||||||
|
|||||||
@@ -207,7 +207,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
public MiniYaml Save()
|
public MiniYaml Save()
|
||||||
{
|
{
|
||||||
Func<object, bool> saveInit = init =>
|
bool SaveInit(ActorInit init)
|
||||||
{
|
{
|
||||||
if (init is FactionInit factionInit && factionInit.Value == Owner.Faction)
|
if (init is FactionInit factionInit && factionInit.Value == Owner.Faction)
|
||||||
return false;
|
return false;
|
||||||
@@ -218,9 +218,9 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
// TODO: Other default values will need to be filtered
|
// TODO: Other default values will need to be filtered
|
||||||
// here after we have built a properties panel
|
// here after we have built a properties panel
|
||||||
return true;
|
return true;
|
||||||
};
|
}
|
||||||
|
|
||||||
return reference.Save(saveInit);
|
return reference.Save(SaveInit);
|
||||||
}
|
}
|
||||||
|
|
||||||
WPos PreviewPosition(World world, ActorReference actor)
|
WPos PreviewPosition(World world, ActorReference actor)
|
||||||
|
|||||||
@@ -303,12 +303,12 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
if (check > BlockedByActor.None)
|
if (check > BlockedByActor.None)
|
||||||
{
|
{
|
||||||
Func<Actor, bool> checkTransient = otherActor => IsBlockedBy(self, otherActor, ignoreActor, cell, check, GetCache(cell).CellFlag);
|
bool CheckTransient(Actor otherActor) => IsBlockedBy(self, otherActor, ignoreActor, cell, check, GetCache(cell).CellFlag);
|
||||||
|
|
||||||
if (!sharesCell)
|
if (!sharesCell)
|
||||||
return world.ActorMap.AnyActorsAt(cell, SubCell.FullCell, checkTransient) ? SubCell.Invalid : SubCell.FullCell;
|
return world.ActorMap.AnyActorsAt(cell, SubCell.FullCell, CheckTransient) ? SubCell.Invalid : SubCell.FullCell;
|
||||||
|
|
||||||
return world.ActorMap.FreeSubCell(cell, preferredSubCell, checkTransient);
|
return world.ActorMap.FreeSubCell(cell, preferredSubCell, CheckTransient);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!sharesCell)
|
if (!sharesCell)
|
||||||
|
|||||||
@@ -26,14 +26,14 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
{
|
{
|
||||||
var missingImages = new HashSet<string>();
|
var missingImages = new HashSet<string>();
|
||||||
var failed = false;
|
var failed = false;
|
||||||
Action<uint, string> onMissingImage = (id, f) =>
|
void OnMissingImage(uint id, string f)
|
||||||
{
|
{
|
||||||
onError($"\tTemplate `{id}` references sprite `{f}` that does not exist.");
|
onError($"\tTemplate `{id}` references sprite `{f}` that does not exist.");
|
||||||
missingImages.Add(f);
|
missingImages.Add(f);
|
||||||
failed = true;
|
failed = true;
|
||||||
};
|
}
|
||||||
|
|
||||||
var tileCache = new DefaultTileCache((DefaultTerrain)terrainInfo, onMissingImage);
|
var tileCache = new DefaultTileCache((DefaultTerrain)terrainInfo, OnMissingImage);
|
||||||
foreach (var t in terrainInfo.Templates)
|
foreach (var t in terrainInfo.Templates)
|
||||||
{
|
{
|
||||||
var templateInfo = (DefaultTerrainTemplateInfo)t.Value;
|
var templateInfo = (DefaultTerrainTemplateInfo)t.Value;
|
||||||
|
|||||||
@@ -235,35 +235,35 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
var ownerDropdown = ownerContainer.Get<DropDownButtonWidget>("OPTION");
|
var ownerDropdown = ownerContainer.Get<DropDownButtonWidget>("OPTION");
|
||||||
var selectedOwner = actor.Owner;
|
var selectedOwner = actor.Owner;
|
||||||
|
|
||||||
Action<EditorActorPreview, PlayerReference> updateOwner = (preview, reference) =>
|
void UpdateOwner(EditorActorPreview preview, PlayerReference reference)
|
||||||
{
|
{
|
||||||
preview.Owner = reference;
|
preview.Owner = reference;
|
||||||
preview.ReplaceInit(new OwnerInit(reference.Name));
|
preview.ReplaceInit(new OwnerInit(reference.Name));
|
||||||
};
|
}
|
||||||
|
|
||||||
var ownerHandler = new EditorActorOptionActionHandle<PlayerReference>(updateOwner, actor.Owner);
|
var ownerHandler = new EditorActorOptionActionHandle<PlayerReference>(UpdateOwner, actor.Owner);
|
||||||
editActorPreview.Add(ownerHandler);
|
editActorPreview.Add(ownerHandler);
|
||||||
|
|
||||||
Func<PlayerReference, ScrollItemWidget, ScrollItemWidget> setupItem = (option, template) =>
|
ScrollItemWidget SetupItem(PlayerReference option, ScrollItemWidget template)
|
||||||
{
|
{
|
||||||
var item = ScrollItemWidget.Setup(template, () => selectedOwner == option, () =>
|
var item = ScrollItemWidget.Setup(template, () => selectedOwner == option, () =>
|
||||||
{
|
{
|
||||||
selectedOwner = option;
|
selectedOwner = option;
|
||||||
updateOwner(CurrentActor, selectedOwner);
|
UpdateOwner(CurrentActor, selectedOwner);
|
||||||
ownerHandler.OnChange(option);
|
ownerHandler.OnChange(option);
|
||||||
});
|
});
|
||||||
|
|
||||||
item.Get<LabelWidget>("LABEL").GetText = () => option.Name;
|
item.Get<LabelWidget>("LABEL").GetText = () => option.Name;
|
||||||
item.GetColor = () => option.Color;
|
item.GetColor = () => option.Color;
|
||||||
return item;
|
return item;
|
||||||
};
|
}
|
||||||
|
|
||||||
ownerDropdown.GetText = () => selectedOwner.Name;
|
ownerDropdown.GetText = () => selectedOwner.Name;
|
||||||
ownerDropdown.GetColor = () => selectedOwner.Color;
|
ownerDropdown.GetColor = () => selectedOwner.Color;
|
||||||
ownerDropdown.OnClick = () =>
|
ownerDropdown.OnClick = () =>
|
||||||
{
|
{
|
||||||
var owners = editorActorLayer.Players.Players.Values.OrderBy(p => p.Name);
|
var owners = editorActorLayer.Players.Players.Values.OrderBy(p => p.Name);
|
||||||
ownerDropdown.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 270, owners, setupItem);
|
ownerDropdown.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 270, owners, SetupItem);
|
||||||
};
|
};
|
||||||
|
|
||||||
initContainer.Bounds.Height += ownerContainer.Bounds.Height;
|
initContainer.Bounds.Height += ownerContainer.Bounds.Height;
|
||||||
@@ -320,9 +320,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
var valueField = sliderContainer.GetOrNull<TextFieldWidget>("VALUE");
|
var valueField = sliderContainer.GetOrNull<TextFieldWidget>("VALUE");
|
||||||
if (valueField != null)
|
if (valueField != null)
|
||||||
{
|
{
|
||||||
Action<float> updateValueField = f => valueField.Text = ((int)f).ToString();
|
void UpdateValueField(float f) => valueField.Text = ((int)f).ToString();
|
||||||
updateValueField(so.GetValue(actor));
|
UpdateValueField(so.GetValue(actor));
|
||||||
slider.OnChange += updateValueField;
|
slider.OnChange += UpdateValueField;
|
||||||
|
|
||||||
valueField.OnTextEdited = () =>
|
valueField.OnTextEdited = () =>
|
||||||
{
|
{
|
||||||
@@ -348,7 +348,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
editActorPreview.Add(editorActionHandle);
|
editActorPreview.Add(editorActionHandle);
|
||||||
|
|
||||||
var dropdown = dropdownContainer.Get<DropDownButtonWidget>("OPTION");
|
var dropdown = dropdownContainer.Get<DropDownButtonWidget>("OPTION");
|
||||||
Func<KeyValuePair<string, string>, ScrollItemWidget, ScrollItemWidget> dropdownSetup = (option, template) =>
|
ScrollItemWidget DropdownSetup(KeyValuePair<string, string> option, ScrollItemWidget template)
|
||||||
{
|
{
|
||||||
var item = ScrollItemWidget.Setup(template,
|
var item = ScrollItemWidget.Setup(template,
|
||||||
() => ddo.GetValue(actor) == option.Key,
|
() => ddo.GetValue(actor) == option.Key,
|
||||||
@@ -360,10 +360,10 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
|
|
||||||
item.Get<LabelWidget>("LABEL").GetText = () => option.Value;
|
item.Get<LabelWidget>("LABEL").GetText = () => option.Value;
|
||||||
return item;
|
return item;
|
||||||
};
|
}
|
||||||
|
|
||||||
dropdown.GetText = () => ddo.Labels[ddo.GetValue(actor)];
|
dropdown.GetText = () => ddo.Labels[ddo.GetValue(actor)];
|
||||||
dropdown.OnClick = () => dropdown.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 270, ddo.Labels, dropdownSetup);
|
dropdown.OnClick = () => dropdown.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 270, ddo.Labels, DropdownSetup);
|
||||||
|
|
||||||
initContainer.AddChild(dropdownContainer);
|
initContainer.AddChild(dropdownContainer);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
var editorLayer = world.WorldActor.Trait<EditorActorLayer>();
|
var editorLayer = world.WorldActor.Trait<EditorActorLayer>();
|
||||||
|
|
||||||
selectedOwner = editorLayer.Players.Players.Values.First();
|
selectedOwner = editorLayer.Players.Players.Values.First();
|
||||||
Func<PlayerReference, ScrollItemWidget, ScrollItemWidget> setupItem = (option, template) =>
|
ScrollItemWidget SetupItem(PlayerReference option, ScrollItemWidget template)
|
||||||
{
|
{
|
||||||
var item = ScrollItemWidget.Setup(template, () => selectedOwner == option, () => SelectOwner(option));
|
var item = ScrollItemWidget.Setup(template, () => selectedOwner == option, () => SelectOwner(option));
|
||||||
|
|
||||||
@@ -65,7 +65,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
item.GetColor = () => option.Color;
|
item.GetColor = () => option.Color;
|
||||||
|
|
||||||
return item;
|
return item;
|
||||||
};
|
}
|
||||||
|
|
||||||
editorLayer.OnPlayerRemoved = () =>
|
editorLayer.OnPlayerRemoved = () =>
|
||||||
{
|
{
|
||||||
@@ -77,7 +77,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
ownersDropDown.OnClick = () =>
|
ownersDropDown.OnClick = () =>
|
||||||
{
|
{
|
||||||
var owners = editorLayer.Players.Players.Values.OrderBy(p => p.Name);
|
var owners = editorLayer.Players.Players.Values.OrderBy(p => p.Name);
|
||||||
ownersDropDown.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 270, owners, setupItem);
|
ownersDropDown.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 270, owners, SetupItem);
|
||||||
};
|
};
|
||||||
|
|
||||||
ownersDropDown.Text = selectedOwner.Name;
|
ownersDropDown.Text = selectedOwner.Name;
|
||||||
|
|||||||
@@ -29,18 +29,18 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
|
|
||||||
var tilesetDropDown = panel.Get<DropDownButtonWidget>("TILESET");
|
var tilesetDropDown = panel.Get<DropDownButtonWidget>("TILESET");
|
||||||
var tilesets = modData.DefaultTerrainInfo.Keys;
|
var tilesets = modData.DefaultTerrainInfo.Keys;
|
||||||
Func<string, ScrollItemWidget, ScrollItemWidget> setupItem = (option, template) =>
|
ScrollItemWidget SetupItem(string option, ScrollItemWidget template)
|
||||||
{
|
{
|
||||||
var item = ScrollItemWidget.Setup(template,
|
var item = ScrollItemWidget.Setup(template,
|
||||||
() => tilesetDropDown.Text == option,
|
() => tilesetDropDown.Text == option,
|
||||||
() => { tilesetDropDown.Text = option; });
|
() => { tilesetDropDown.Text = option; });
|
||||||
item.Get<LabelWidget>("LABEL").GetText = () => option;
|
item.Get<LabelWidget>("LABEL").GetText = () => option;
|
||||||
return item;
|
return item;
|
||||||
};
|
}
|
||||||
|
|
||||||
tilesetDropDown.Text = tilesets.First();
|
tilesetDropDown.Text = tilesets.First();
|
||||||
tilesetDropDown.OnClick = () =>
|
tilesetDropDown.OnClick = () =>
|
||||||
tilesetDropDown.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 210, tilesets, setupItem);
|
tilesetDropDown.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 210, tilesets, SetupItem);
|
||||||
|
|
||||||
var widthTextField = panel.Get<TextFieldWidget>("WIDTH");
|
var widthTextField = panel.Get<TextFieldWidget>("WIDTH");
|
||||||
var heightTextField = panel.Get<TextFieldWidget>("HEIGHT");
|
var heightTextField = panel.Get<TextFieldWidget>("HEIGHT");
|
||||||
|
|||||||
@@ -115,14 +115,14 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
|
|
||||||
var directoryDropdown = widget.Get<DropDownButtonWidget>("DIRECTORY_DROPDOWN");
|
var directoryDropdown = widget.Get<DropDownButtonWidget>("DIRECTORY_DROPDOWN");
|
||||||
{
|
{
|
||||||
Func<SaveDirectory, ScrollItemWidget, ScrollItemWidget> setupItem = (option, template) =>
|
ScrollItemWidget SetupItem(SaveDirectory option, ScrollItemWidget template)
|
||||||
{
|
{
|
||||||
var item = ScrollItemWidget.Setup(template,
|
var item = ScrollItemWidget.Setup(template,
|
||||||
() => selectedDirectory == option,
|
() => selectedDirectory == option,
|
||||||
() => selectedDirectory = option);
|
() => selectedDirectory = option);
|
||||||
item.Get<LabelWidget>("LABEL").GetText = () => option.DisplayName;
|
item.Get<LabelWidget>("LABEL").GetText = () => option.DisplayName;
|
||||||
return item;
|
return item;
|
||||||
};
|
}
|
||||||
|
|
||||||
foreach (var kv in modData.MapCache.MapLocations)
|
foreach (var kv in modData.MapCache.MapLocations)
|
||||||
{
|
{
|
||||||
@@ -157,7 +157,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
|
|
||||||
directoryDropdown.GetText = () => selectedDirectory?.DisplayName ?? "";
|
directoryDropdown.GetText = () => selectedDirectory?.DisplayName ?? "";
|
||||||
directoryDropdown.OnClick = () =>
|
directoryDropdown.OnClick = () =>
|
||||||
directoryDropdown.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 210, writableDirectories, setupItem);
|
directoryDropdown.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 210, writableDirectories, SetupItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
var mapIsUnpacked = map.Package != null && map.Package is Folder;
|
var mapIsUnpacked = map.Package != null && map.Package is Folder;
|
||||||
@@ -177,25 +177,25 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
|
|
||||||
var typeDropdown = widget.Get<DropDownButtonWidget>("TYPE_DROPDOWN");
|
var typeDropdown = widget.Get<DropDownButtonWidget>("TYPE_DROPDOWN");
|
||||||
{
|
{
|
||||||
Func<KeyValuePair<MapFileType, MapFileTypeInfo>, ScrollItemWidget, ScrollItemWidget> setupItem = (option, template) =>
|
ScrollItemWidget SetupItem(KeyValuePair<MapFileType, MapFileTypeInfo> option, ScrollItemWidget template)
|
||||||
{
|
{
|
||||||
var item = ScrollItemWidget.Setup(template,
|
var item = ScrollItemWidget.Setup(template,
|
||||||
() => fileType == option.Key,
|
() => fileType == option.Key,
|
||||||
() => { typeDropdown.Text = option.Value.UiLabel; fileType = option.Key; });
|
() => { typeDropdown.Text = option.Value.UiLabel; fileType = option.Key; });
|
||||||
item.Get<LabelWidget>("LABEL").GetText = () => option.Value.UiLabel;
|
item.Get<LabelWidget>("LABEL").GetText = () => option.Value.UiLabel;
|
||||||
return item;
|
return item;
|
||||||
};
|
}
|
||||||
|
|
||||||
typeDropdown.Text = fileTypes[fileType].UiLabel;
|
typeDropdown.Text = fileTypes[fileType].UiLabel;
|
||||||
|
|
||||||
typeDropdown.OnClick = () =>
|
typeDropdown.OnClick = () =>
|
||||||
typeDropdown.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 210, fileTypes, setupItem);
|
typeDropdown.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 210, fileTypes, SetupItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
var close = widget.Get<ButtonWidget>("BACK_BUTTON");
|
var close = widget.Get<ButtonWidget>("BACK_BUTTON");
|
||||||
close.OnClick = () => { Ui.CloseWindow(); onExit(); };
|
close.OnClick = () => { Ui.CloseWindow(); onExit(); };
|
||||||
|
|
||||||
Action<string> saveMap = (string combinedPath) =>
|
void SaveMap(string combinedPath)
|
||||||
{
|
{
|
||||||
map.Title = title.Text;
|
map.Title = title.Text;
|
||||||
map.Author = author.Text;
|
map.Author = author.Text;
|
||||||
@@ -228,7 +228,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
}
|
}
|
||||||
|
|
||||||
onSave(map.Uid);
|
onSave(map.Uid);
|
||||||
};
|
}
|
||||||
|
|
||||||
var save = widget.Get<ButtonWidget>("SAVE_BUTTON");
|
var save = widget.Get<ButtonWidget>("SAVE_BUTTON");
|
||||||
save.IsDisabled = () => string.IsNullOrWhiteSpace(filename.Text) || string.IsNullOrWhiteSpace(title.Text) || string.IsNullOrWhiteSpace(author.Text);
|
save.IsDisabled = () => string.IsNullOrWhiteSpace(filename.Text) || string.IsNullOrWhiteSpace(title.Text) || string.IsNullOrWhiteSpace(author.Text);
|
||||||
@@ -236,7 +236,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
save.OnClick = () =>
|
save.OnClick = () =>
|
||||||
{
|
{
|
||||||
var combinedPath = Platform.ResolvePath(Path.Combine(selectedDirectory.Folder.Name, filename.Text + fileTypes[fileType].Extension));
|
var combinedPath = Platform.ResolvePath(Path.Combine(selectedDirectory.Folder.Name, filename.Text + fileTypes[fileType].Extension));
|
||||||
SaveMap(modData, world, map, combinedPath, saveMap);
|
SaveMapLogic.SaveMap(modData, world, map, combinedPath, SaveMap);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -352,12 +352,12 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
modData.Manifest.Metadata.Version,
|
modData.Manifest.Metadata.Version,
|
||||||
filename);
|
filename);
|
||||||
|
|
||||||
Action inner = () =>
|
void Inner()
|
||||||
{
|
{
|
||||||
world.RequestGameSave(filename);
|
world.RequestGameSave(filename);
|
||||||
Ui.CloseWindow();
|
Ui.CloseWindow();
|
||||||
onExit();
|
onExit();
|
||||||
};
|
}
|
||||||
|
|
||||||
if (selectedSave != null || File.Exists(testPath))
|
if (selectedSave != null || File.Exists(testPath))
|
||||||
{
|
{
|
||||||
@@ -365,12 +365,12 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
title: OverwriteSaveTitle,
|
title: OverwriteSaveTitle,
|
||||||
text: OverwriteSavePrompt,
|
text: OverwriteSavePrompt,
|
||||||
textArguments: Translation.Arguments("file", saveTextField.Text),
|
textArguments: Translation.Arguments("file", saveTextField.Text),
|
||||||
onConfirm: inner,
|
onConfirm: Inner,
|
||||||
confirmText: OverwriteSaveAccpet,
|
confirmText: OverwriteSaveAccpet,
|
||||||
onCancel: () => { });
|
onCancel: () => { });
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
inner();
|
Inner();
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnGameStart()
|
void OnGameStart()
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
.Where(q => (q.Info.Group ?? q.Info.Type) == button.ProductionGroup)
|
.Where(q => (q.Info.Group ?? q.Info.Type) == button.ProductionGroup)
|
||||||
.ToArray();
|
.ToArray();
|
||||||
|
|
||||||
Action<bool> selectTab = reverse =>
|
void SelectTab(bool reverse)
|
||||||
{
|
{
|
||||||
palette.CurrentQueue = queues.FirstOrDefault(q => q.Enabled);
|
palette.CurrentQueue = queues.FirstOrDefault(q => q.Enabled);
|
||||||
|
|
||||||
@@ -40,12 +40,12 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
|
|
||||||
// Attempt to pick up a completed building (if there is one) so it can be placed
|
// Attempt to pick up a completed building (if there is one) so it can be placed
|
||||||
palette.PickUpCompletedBuilding();
|
palette.PickUpCompletedBuilding();
|
||||||
};
|
}
|
||||||
|
|
||||||
button.IsDisabled = () => !queues.Any(q => q.BuildableItems().Any());
|
button.IsDisabled = () => !queues.Any(q => q.BuildableItems().Any());
|
||||||
button.OnMouseUp = mi => selectTab(mi.Modifiers.HasModifier(Modifiers.Shift));
|
button.OnMouseUp = mi => SelectTab(mi.Modifiers.HasModifier(Modifiers.Shift));
|
||||||
button.OnKeyPress = e => selectTab(e.Modifiers.HasModifier(Modifiers.Shift));
|
button.OnKeyPress = e => SelectTab(e.Modifiers.HasModifier(Modifiers.Shift));
|
||||||
button.OnClick = () => selectTab(false);
|
button.OnClick = () => SelectTab(false);
|
||||||
button.IsHighlighted = () => queues.Contains(palette.CurrentQueue);
|
button.IsHighlighted = () => queues.Contains(palette.CurrentQueue);
|
||||||
|
|
||||||
var chromeName = button.ProductionGroup.ToLowerInvariant();
|
var chromeName = button.ProductionGroup.ToLowerInvariant();
|
||||||
@@ -77,7 +77,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
if (foreground != null)
|
if (foreground != null)
|
||||||
foregroundTemplate = foreground.Get("ROW_TEMPLATE");
|
foregroundTemplate = foreground.Get("ROW_TEMPLATE");
|
||||||
|
|
||||||
Action<int, int> updateBackground = (_, icons) =>
|
void UpdateBackground(int _, int icons)
|
||||||
{
|
{
|
||||||
var rows = Math.Max(palette.MinimumRows, (icons + palette.Columns - 1) / palette.Columns);
|
var rows = Math.Max(palette.MinimumRows, (icons + palette.Columns - 1) / palette.Columns);
|
||||||
rows = Math.Min(rows, palette.MaximumRows);
|
rows = Math.Min(rows, palette.MaximumRows);
|
||||||
@@ -113,12 +113,12 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
foreground.AddChild(row);
|
foreground.AddChild(row);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
palette.OnIconCountChanged += updateBackground;
|
palette.OnIconCountChanged += UpdateBackground;
|
||||||
|
|
||||||
// Set the initial palette state
|
// Set the initial palette state
|
||||||
updateBackground(0, 0);
|
UpdateBackground(0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
var typesContainer = widget.Get("PRODUCTION_TYPES");
|
var typesContainer = widget.Get("PRODUCTION_TYPES");
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ namespace OpenRA.Mods.Common.Widgets
|
|||||||
attackMoveButton.IsDisabled = () => { UpdateStateIfNecessary(); return attackMoveDisabled; };
|
attackMoveButton.IsDisabled = () => { UpdateStateIfNecessary(); return attackMoveDisabled; };
|
||||||
attackMoveButton.IsHighlighted = () => world.OrderGenerator is AttackMoveOrderGenerator;
|
attackMoveButton.IsHighlighted = () => world.OrderGenerator is AttackMoveOrderGenerator;
|
||||||
|
|
||||||
Action<bool> toggle = allowCancel =>
|
void Toggle(bool allowCancel)
|
||||||
{
|
{
|
||||||
if (attackMoveButton.IsHighlighted())
|
if (attackMoveButton.IsHighlighted())
|
||||||
{
|
{
|
||||||
@@ -66,10 +66,10 @@ namespace OpenRA.Mods.Common.Widgets
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
world.OrderGenerator = new AttackMoveOrderGenerator(selectedActors, Game.Settings.Game.MouseButtonPreference.Action);
|
world.OrderGenerator = new AttackMoveOrderGenerator(selectedActors, Game.Settings.Game.MouseButtonPreference.Action);
|
||||||
};
|
}
|
||||||
|
|
||||||
attackMoveButton.OnClick = () => toggle(true);
|
attackMoveButton.OnClick = () => Toggle(true);
|
||||||
attackMoveButton.OnKeyPress = _ => toggle(false);
|
attackMoveButton.OnKeyPress = _ => Toggle(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
var forceMoveButton = widget.GetOrNull<ButtonWidget>("FORCE_MOVE");
|
var forceMoveButton = widget.GetOrNull<ButtonWidget>("FORCE_MOVE");
|
||||||
@@ -114,7 +114,7 @@ namespace OpenRA.Mods.Common.Widgets
|
|||||||
guardButton.IsDisabled = () => { UpdateStateIfNecessary(); return guardDisabled; };
|
guardButton.IsDisabled = () => { UpdateStateIfNecessary(); return guardDisabled; };
|
||||||
guardButton.IsHighlighted = () => world.OrderGenerator is GuardOrderGenerator;
|
guardButton.IsHighlighted = () => world.OrderGenerator is GuardOrderGenerator;
|
||||||
|
|
||||||
Action<bool> toggle = allowCancel =>
|
void Toggle(bool allowCancel)
|
||||||
{
|
{
|
||||||
if (guardButton.IsHighlighted())
|
if (guardButton.IsHighlighted())
|
||||||
{
|
{
|
||||||
@@ -124,10 +124,10 @@ namespace OpenRA.Mods.Common.Widgets
|
|||||||
else
|
else
|
||||||
world.OrderGenerator = new GuardOrderGenerator(selectedActors,
|
world.OrderGenerator = new GuardOrderGenerator(selectedActors,
|
||||||
"Guard", "guard", Game.Settings.Game.MouseButtonPreference.Action);
|
"Guard", "guard", Game.Settings.Game.MouseButtonPreference.Action);
|
||||||
};
|
}
|
||||||
|
|
||||||
guardButton.OnClick = () => toggle(true);
|
guardButton.OnClick = () => Toggle(true);
|
||||||
guardButton.OnKeyPress = _ => toggle(false);
|
guardButton.OnKeyPress = _ => Toggle(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
var scatterButton = widget.GetOrNull<ButtonWidget>("SCATTER");
|
var scatterButton = widget.GetOrNull<ButtonWidget>("SCATTER");
|
||||||
|
|||||||
@@ -9,7 +9,6 @@
|
|||||||
*/
|
*/
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using OpenRA.Mods.Common.Traits;
|
using OpenRA.Mods.Common.Traits;
|
||||||
using OpenRA.Primitives;
|
using OpenRA.Primitives;
|
||||||
@@ -62,12 +61,13 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
|
|
||||||
PopulateObjectivesList(mo, objectivesPanel, template);
|
PopulateObjectivesList(mo, objectivesPanel, template);
|
||||||
|
|
||||||
Action<Player, bool> redrawObjectives = (p, _) =>
|
void RedrawObjectives(Player p, bool _)
|
||||||
{
|
{
|
||||||
if (p == player)
|
if (p == player)
|
||||||
PopulateObjectivesList(mo, objectivesPanel, template);
|
PopulateObjectivesList(mo, objectivesPanel, template);
|
||||||
};
|
}
|
||||||
mo.ObjectiveAdded += redrawObjectives;
|
|
||||||
|
mo.ObjectiveAdded += RedrawObjectives;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void PopulateObjectivesList(MissionObjectives mo, ScrollPanelWidget parent, ContainerWidget template)
|
static void PopulateObjectivesList(MissionObjectives mo, ScrollPanelWidget parent, ContainerWidget template)
|
||||||
|
|||||||
@@ -38,12 +38,12 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
var tlm = world.WorldActor.TraitOrDefault<TimeLimitManager>();
|
var tlm = world.WorldActor.TraitOrDefault<TimeLimitManager>();
|
||||||
var startTick = Ui.LastTickTime.Value;
|
var startTick = Ui.LastTickTime.Value;
|
||||||
|
|
||||||
Func<bool> shouldShowStatus = () => (world.Paused || world.ReplayTimestep != world.Timestep)
|
bool ShouldShowStatus() => (world.Paused || world.ReplayTimestep != world.Timestep)
|
||||||
&& (Ui.LastTickTime.Value - startTick) / 1000 % 2 == 0;
|
&& (Ui.LastTickTime.Value - startTick) / 1000 % 2 == 0;
|
||||||
|
|
||||||
Func<bool> paused = () => world.Paused || world.ReplayTimestep == 0;
|
bool Paused() => world.Paused || world.ReplayTimestep == 0;
|
||||||
|
|
||||||
var pausedText = modData.Translation.GetString(Paused);
|
var pausedText = modData.Translation.GetString(GameTimerLogic.Paused);
|
||||||
var maxSpeedText = modData.Translation.GetString(MaxSpeed);
|
var maxSpeedText = modData.Translation.GetString(MaxSpeed);
|
||||||
var speedText = new CachedTransform<int, string>(p =>
|
var speedText = new CachedTransform<int, string>(p =>
|
||||||
modData.Translation.GetString(Speed, Translation.Arguments("percentage", p)));
|
modData.Translation.GetString(Speed, Translation.Arguments("percentage", p)));
|
||||||
@@ -52,7 +52,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
{
|
{
|
||||||
timer.GetText = () =>
|
timer.GetText = () =>
|
||||||
{
|
{
|
||||||
if (status == null && paused() && shouldShowStatus())
|
if (status == null && Paused() && ShouldShowStatus())
|
||||||
return pausedText;
|
return pausedText;
|
||||||
|
|
||||||
var timeLimit = tlm?.TimeLimit ?? 0;
|
var timeLimit = tlm?.TimeLimit ?? 0;
|
||||||
@@ -64,10 +64,10 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
if (status != null)
|
if (status != null)
|
||||||
{
|
{
|
||||||
// Blink the status line
|
// Blink the status line
|
||||||
status.IsVisible = shouldShowStatus;
|
status.IsVisible = ShouldShowStatus;
|
||||||
status.GetText = () =>
|
status.GetText = () =>
|
||||||
{
|
{
|
||||||
if (paused())
|
if (Paused())
|
||||||
return pausedText;
|
return pausedText;
|
||||||
|
|
||||||
if (world.ReplayTimestep == 1)
|
if (world.ReplayTimestep == 1)
|
||||||
|
|||||||
@@ -9,7 +9,6 @@
|
|||||||
*/
|
*/
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using OpenRA.Mods.Common.Traits;
|
using OpenRA.Mods.Common.Traits;
|
||||||
using OpenRA.Widgets;
|
using OpenRA.Widgets;
|
||||||
@@ -30,7 +29,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
var locomotorSelector = widget.Get<DropDownButtonWidget>("HPF_OVERLAY_LOCOMOTOR");
|
var locomotorSelector = widget.Get<DropDownButtonWidget>("HPF_OVERLAY_LOCOMOTOR");
|
||||||
locomotorSelector.OnMouseDown = _ =>
|
locomotorSelector.OnMouseDown = _ =>
|
||||||
{
|
{
|
||||||
Func<Locomotor, ScrollItemWidget, ScrollItemWidget> setupItem = (option, template) =>
|
ScrollItemWidget SetupItem(Locomotor option, ScrollItemWidget template)
|
||||||
{
|
{
|
||||||
var item = ScrollItemWidget.Setup(
|
var item = ScrollItemWidget.Setup(
|
||||||
template,
|
template,
|
||||||
@@ -38,16 +37,16 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
() => hpfOverlay.Locomotor = option);
|
() => hpfOverlay.Locomotor = option);
|
||||||
item.Get<LabelWidget>("LABEL").GetText = () => option?.Info.Name ?? "(Selected Units)";
|
item.Get<LabelWidget>("LABEL").GetText = () => option?.Info.Name ?? "(Selected Units)";
|
||||||
return item;
|
return item;
|
||||||
};
|
}
|
||||||
|
|
||||||
locomotorSelector.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", locomotors.Length * 30, locomotors, setupItem);
|
locomotorSelector.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", locomotors.Length * 30, locomotors, SetupItem);
|
||||||
};
|
};
|
||||||
|
|
||||||
var checks = new[] { BlockedByActor.None, BlockedByActor.Immovable };
|
var checks = new[] { BlockedByActor.None, BlockedByActor.Immovable };
|
||||||
var checkSelector = widget.Get<DropDownButtonWidget>("HPF_OVERLAY_CHECK");
|
var checkSelector = widget.Get<DropDownButtonWidget>("HPF_OVERLAY_CHECK");
|
||||||
checkSelector.OnMouseDown = _ =>
|
checkSelector.OnMouseDown = _ =>
|
||||||
{
|
{
|
||||||
Func<BlockedByActor, ScrollItemWidget, ScrollItemWidget> setupItem = (option, template) =>
|
ScrollItemWidget SetupItem(BlockedByActor option, ScrollItemWidget template)
|
||||||
{
|
{
|
||||||
var item = ScrollItemWidget.Setup(
|
var item = ScrollItemWidget.Setup(
|
||||||
template,
|
template,
|
||||||
@@ -55,9 +54,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
() => hpfOverlay.Check = option);
|
() => hpfOverlay.Check = option);
|
||||||
item.Get<LabelWidget>("LABEL").GetText = () => option.ToString();
|
item.Get<LabelWidget>("LABEL").GetText = () => option.ToString();
|
||||||
return item;
|
return item;
|
||||||
};
|
}
|
||||||
|
|
||||||
checkSelector.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", checks.Length * 30, checks, setupItem);
|
checkSelector.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", checks.Length * 30, checks, SetupItem);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,6 @@
|
|||||||
*/
|
*/
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using OpenRA.FileSystem;
|
using OpenRA.FileSystem;
|
||||||
using OpenRA.Mods.Common.Lint;
|
using OpenRA.Mods.Common.Lint;
|
||||||
@@ -39,7 +38,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic.Ingame
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
var map = world.Map;
|
var map = world.Map;
|
||||||
Action<string> saveMap = (string combinedPath) =>
|
void SaveMap(string combinedPath)
|
||||||
{
|
{
|
||||||
var editorActorLayer = world.WorldActor.Trait<EditorActorLayer>();
|
var editorActorLayer = world.WorldActor.Trait<EditorActorLayer>();
|
||||||
|
|
||||||
@@ -53,9 +52,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic.Ingame
|
|||||||
|
|
||||||
var package = (IReadWritePackage)map.Package;
|
var package = (IReadWritePackage)map.Package;
|
||||||
SaveMapLogic.SaveMapInner(map, package, world, modData);
|
SaveMapLogic.SaveMapInner(map, package, world, modData);
|
||||||
};
|
}
|
||||||
|
|
||||||
SaveMapLogic.SaveMap(modData, world, map, map.Package?.Name, saveMap);
|
SaveMapLogic.SaveMap(modData, world, map, map.Package?.Name, SaveMap);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -310,7 +310,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
var iop = world.WorldActor.TraitsImplementing<IObjectivesPanel>().FirstOrDefault();
|
var iop = world.WorldActor.TraitsImplementing<IObjectivesPanel>().FirstOrDefault();
|
||||||
var exitDelay = iop?.ExitDelay ?? 0;
|
var exitDelay = iop?.ExitDelay ?? 0;
|
||||||
|
|
||||||
Action onRestart = () =>
|
void OnRestart()
|
||||||
{
|
{
|
||||||
Ui.CloseWindow();
|
Ui.CloseWindow();
|
||||||
if (mpe != null)
|
if (mpe != null)
|
||||||
@@ -321,7 +321,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
}
|
}
|
||||||
|
|
||||||
Game.RunAfterDelay(exitDelay, Game.RestartGame);
|
Game.RunAfterDelay(exitDelay, Game.RestartGame);
|
||||||
};
|
}
|
||||||
|
|
||||||
var button = AddButton("RESTART", RestartButton);
|
var button = AddButton("RESTART", RestartButton);
|
||||||
button.IsDisabled = () => hasError || leaving;
|
button.IsDisabled = () => hasError || leaving;
|
||||||
@@ -331,7 +331,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
ConfirmationDialogs.ButtonPrompt(modData,
|
ConfirmationDialogs.ButtonPrompt(modData,
|
||||||
title: RestartMissionTitle,
|
title: RestartMissionTitle,
|
||||||
text: RestartMissionPrompt,
|
text: RestartMissionPrompt,
|
||||||
onConfirm: onRestart,
|
onConfirm: OnRestart,
|
||||||
onCancel: ShowMenu,
|
onCancel: ShowMenu,
|
||||||
confirmText: RestartMissionAccept,
|
confirmText: RestartMissionAccept,
|
||||||
cancelText: RestartMissionCancel);
|
cancelText: RestartMissionCancel);
|
||||||
@@ -343,11 +343,11 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
if (world.Type != WorldType.Regular || isSinglePlayer || world.LocalPlayer == null)
|
if (world.Type != WorldType.Regular || isSinglePlayer || world.LocalPlayer == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Action onSurrender = () =>
|
void OnSurrender()
|
||||||
{
|
{
|
||||||
world.IssueOrder(new Order("Surrender", world.LocalPlayer.PlayerActor, false));
|
world.IssueOrder(new Order("Surrender", world.LocalPlayer.PlayerActor, false));
|
||||||
CloseMenu();
|
CloseMenu();
|
||||||
};
|
}
|
||||||
|
|
||||||
var button = AddButton("SURRENDER", SurrenderButton);
|
var button = AddButton("SURRENDER", SurrenderButton);
|
||||||
button.IsDisabled = () => world.LocalPlayer.WinState != WinState.Undefined || hasError || leaving;
|
button.IsDisabled = () => world.LocalPlayer.WinState != WinState.Undefined || hasError || leaving;
|
||||||
@@ -357,7 +357,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
ConfirmationDialogs.ButtonPrompt(modData,
|
ConfirmationDialogs.ButtonPrompt(modData,
|
||||||
title: SurrenderTitle,
|
title: SurrenderTitle,
|
||||||
text: SurrenderPrompt,
|
text: SurrenderPrompt,
|
||||||
onConfirm: onSurrender,
|
onConfirm: OnSurrender,
|
||||||
onCancel: ShowMenu,
|
onCancel: ShowMenu,
|
||||||
confirmText: SurrenderAccept,
|
confirmText: SurrenderAccept,
|
||||||
cancelText: SurrenderCancel);
|
cancelText: SurrenderCancel);
|
||||||
|
|||||||
@@ -9,7 +9,6 @@
|
|||||||
*/
|
*/
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using OpenRA.Mods.Common.Traits;
|
using OpenRA.Mods.Common.Traits;
|
||||||
using OpenRA.Widgets;
|
using OpenRA.Widgets;
|
||||||
@@ -52,16 +51,16 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
|
|
||||||
if (lp != null)
|
if (lp != null)
|
||||||
{
|
{
|
||||||
Action<Player, bool> startBlinking = (player, inhibitAnnouncement) =>
|
void StartBlinking(Player player, bool inhibitAnnouncement)
|
||||||
{
|
{
|
||||||
if (!inhibitAnnouncement && player == world.LocalPlayer)
|
if (!inhibitAnnouncement && player == world.LocalPlayer)
|
||||||
blinking = true;
|
blinking = true;
|
||||||
};
|
}
|
||||||
|
|
||||||
var mo = lp.PlayerActor.TraitOrDefault<MissionObjectives>();
|
var mo = lp.PlayerActor.TraitOrDefault<MissionObjectives>();
|
||||||
|
|
||||||
if (mo != null)
|
if (mo != null)
|
||||||
mo.ObjectiveAdded += startBlinking;
|
mo.ObjectiveAdded += StartBlinking;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -131,7 +131,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
shroudSelector.IsDisabled = () => shroudSelectorDisabled;
|
shroudSelector.IsDisabled = () => shroudSelectorDisabled;
|
||||||
shroudSelector.OnMouseDown = _ =>
|
shroudSelector.OnMouseDown = _ =>
|
||||||
{
|
{
|
||||||
Func<CameraOption, ScrollItemWidget, ScrollItemWidget> setupItem = (option, template) =>
|
ScrollItemWidget SetupItem(CameraOption option, ScrollItemWidget template)
|
||||||
{
|
{
|
||||||
var item = ScrollItemWidget.Setup(template, option.IsSelected, option.OnClick);
|
var item = ScrollItemWidget.Setup(template, option.IsSelected, option.OnClick);
|
||||||
var showFlag = option.Faction != null;
|
var showFlag = option.Faction != null;
|
||||||
@@ -156,9 +156,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
labelAlt.GetColor = () => option.Color;
|
labelAlt.GetColor = () => option.Color;
|
||||||
|
|
||||||
return item;
|
return item;
|
||||||
};
|
}
|
||||||
|
|
||||||
shroudSelector.ShowDropDown("SPECTATOR_DROPDOWN_TEMPLATE", 400, groups, setupItem);
|
shroudSelector.ShowDropDown("SPECTATOR_DROPDOWN_TEMPLATE", 400, groups, SetupItem);
|
||||||
};
|
};
|
||||||
|
|
||||||
shroudLabel = shroudSelector.Get<LabelWidget>("LABEL");
|
shroudLabel = shroudSelector.Get<LabelWidget>("LABEL");
|
||||||
|
|||||||
@@ -142,7 +142,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
teamTemplate = playerStatsPanel.Get<ScrollItemWidget>("TEAM_TEMPLATE");
|
teamTemplate = playerStatsPanel.Get<ScrollItemWidget>("TEAM_TEMPLATE");
|
||||||
|
|
||||||
var statsDropDown = widget.Get<DropDownButtonWidget>("STATS_DROPDOWN");
|
var statsDropDown = widget.Get<DropDownButtonWidget>("STATS_DROPDOWN");
|
||||||
Func<string, ObserverStatsPanel, ScrollItemWidget, Action, StatsDropDownOption> createStatsOption = (title, panel, template, a) =>
|
StatsDropDownOption CreateStatsOption(string title, ObserverStatsPanel panel, ScrollItemWidget template, Action a)
|
||||||
{
|
{
|
||||||
title = modData.Translation.GetString(title);
|
title = modData.Translation.GetString(title);
|
||||||
return new StatsDropDownOption
|
return new StatsDropDownOption
|
||||||
@@ -162,7 +162,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
Ui.ResetTooltips();
|
Ui.ResetTooltips();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
};
|
}
|
||||||
|
|
||||||
var statsDropDownOptions = new StatsDropDownOption[]
|
var statsDropDownOptions = new StatsDropDownOption[]
|
||||||
{
|
{
|
||||||
@@ -179,26 +179,26 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
activePanel = ObserverStatsPanel.None;
|
activePanel = ObserverStatsPanel.None;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
createStatsOption(Basic, ObserverStatsPanel.Basic, basicPlayerTemplate, () => DisplayStats(BasicStats, modData)),
|
CreateStatsOption(Basic, ObserverStatsPanel.Basic, basicPlayerTemplate, () => DisplayStats(BasicStats, modData)),
|
||||||
createStatsOption(Economy, ObserverStatsPanel.Economy, economyPlayerTemplate, () => DisplayStats(EconomyStats, modData)),
|
CreateStatsOption(Economy, ObserverStatsPanel.Economy, economyPlayerTemplate, () => DisplayStats(EconomyStats, modData)),
|
||||||
createStatsOption(Production, ObserverStatsPanel.Production, productionPlayerTemplate, () => DisplayStats(ProductionStats, modData)),
|
CreateStatsOption(Production, ObserverStatsPanel.Production, productionPlayerTemplate, () => DisplayStats(ProductionStats, modData)),
|
||||||
createStatsOption(SupportPowers, ObserverStatsPanel.SupportPowers, supportPowersPlayerTemplate, () => DisplayStats(SupportPowerStats, modData)),
|
CreateStatsOption(SupportPowers, ObserverStatsPanel.SupportPowers, supportPowersPlayerTemplate, () => DisplayStats(SupportPowerStats, modData)),
|
||||||
createStatsOption(Combat, ObserverStatsPanel.Combat, combatPlayerTemplate, () => DisplayStats(CombatStats, modData)),
|
CreateStatsOption(Combat, ObserverStatsPanel.Combat, combatPlayerTemplate, () => DisplayStats(CombatStats, modData)),
|
||||||
createStatsOption(Army, ObserverStatsPanel.Army, armyPlayerTemplate, () => DisplayStats(ArmyStats, modData)),
|
CreateStatsOption(Army, ObserverStatsPanel.Army, armyPlayerTemplate, () => DisplayStats(ArmyStats, modData)),
|
||||||
createStatsOption(EarningsGraph, ObserverStatsPanel.Graph, null, () => IncomeGraph()),
|
CreateStatsOption(EarningsGraph, ObserverStatsPanel.Graph, null, () => IncomeGraph()),
|
||||||
createStatsOption(ArmyGraph, ObserverStatsPanel.ArmyGraph, null, () => ArmyValueGraph()),
|
CreateStatsOption(ArmyGraph, ObserverStatsPanel.ArmyGraph, null, () => ArmyValueGraph()),
|
||||||
};
|
};
|
||||||
|
|
||||||
Func<StatsDropDownOption, ScrollItemWidget, ScrollItemWidget> setupItem = (option, template) =>
|
ScrollItemWidget SetupItem(StatsDropDownOption option, ScrollItemWidget template)
|
||||||
{
|
{
|
||||||
var item = ScrollItemWidget.Setup(template, option.IsSelected, option.OnClick);
|
var item = ScrollItemWidget.Setup(template, option.IsSelected, option.OnClick);
|
||||||
item.Get<LabelWidget>("LABEL").GetText = () => option.Title;
|
item.Get<LabelWidget>("LABEL").GetText = () => option.Title;
|
||||||
return item;
|
return item;
|
||||||
};
|
}
|
||||||
|
|
||||||
var statsDropDownPanelTemplate = logicArgs.TryGetValue("StatsDropDownPanelTemplate", out yaml) ? yaml.Value : "LABEL_DROPDOWN_TEMPLATE";
|
var statsDropDownPanelTemplate = logicArgs.TryGetValue("StatsDropDownPanelTemplate", out yaml) ? yaml.Value : "LABEL_DROPDOWN_TEMPLATE";
|
||||||
|
|
||||||
statsDropDown.OnMouseDown = _ => statsDropDown.ShowDropDown(statsDropDownPanelTemplate, 230, statsDropDownOptions, setupItem);
|
statsDropDown.OnMouseDown = _ => statsDropDown.ShowDropDown(statsDropDownPanelTemplate, 230, statsDropDownOptions, SetupItem);
|
||||||
statsDropDownOptions[0].OnClick();
|
statsDropDownOptions[0].OnClick();
|
||||||
|
|
||||||
var keyListener = statsDropDown.Get<LogicKeyListenerWidget>("STATS_DROPDOWN_KEYHANDLER");
|
var keyListener = statsDropDown.Get<LogicKeyListenerWidget>("STATS_DROPDOWN_KEYHANDLER");
|
||||||
|
|||||||
@@ -9,7 +9,6 @@
|
|||||||
*/
|
*/
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using OpenRA.Widgets;
|
using OpenRA.Widgets;
|
||||||
|
|
||||||
@@ -25,7 +24,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
if (button == null)
|
if (button == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Action<bool> selectTab = reverse =>
|
void SelectTab(bool reverse)
|
||||||
{
|
{
|
||||||
if (tabs.QueueGroup == button.ProductionGroup)
|
if (tabs.QueueGroup == button.ProductionGroup)
|
||||||
tabs.SelectNextTab(reverse);
|
tabs.SelectNextTab(reverse);
|
||||||
@@ -33,11 +32,11 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
tabs.QueueGroup = button.ProductionGroup;
|
tabs.QueueGroup = button.ProductionGroup;
|
||||||
|
|
||||||
tabs.PickUpCompletedBuilding();
|
tabs.PickUpCompletedBuilding();
|
||||||
};
|
}
|
||||||
|
|
||||||
button.IsDisabled = () => !tabs.Groups[button.ProductionGroup].Tabs.Any(t => t.Queue.BuildableItems().Any());
|
button.IsDisabled = () => !tabs.Groups[button.ProductionGroup].Tabs.Any(t => t.Queue.BuildableItems().Any());
|
||||||
button.OnMouseUp = mi => selectTab(mi.Modifiers.HasModifier(Modifiers.Shift));
|
button.OnMouseUp = mi => SelectTab(mi.Modifiers.HasModifier(Modifiers.Shift));
|
||||||
button.OnKeyPress = e => selectTab(e.Modifiers.HasModifier(Modifiers.Shift));
|
button.OnKeyPress = e => SelectTab(e.Modifiers.HasModifier(Modifiers.Shift));
|
||||||
button.IsHighlighted = () => tabs.QueueGroup == button.ProductionGroup;
|
button.IsHighlighted = () => tabs.QueueGroup == button.ProductionGroup;
|
||||||
|
|
||||||
var chromeName = button.ProductionGroup.ToLowerInvariant();
|
var chromeName = button.ProductionGroup.ToLowerInvariant();
|
||||||
@@ -65,7 +64,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
var palette = tabs.Parent.Get<ProductionPaletteWidget>(tabs.PaletteWidget);
|
var palette = tabs.Parent.Get<ProductionPaletteWidget>(tabs.PaletteWidget);
|
||||||
var icontemplate = background.Get("ICON_TEMPLATE");
|
var icontemplate = background.Get("ICON_TEMPLATE");
|
||||||
|
|
||||||
Action<int, int> updateBackground = (oldCount, newCount) =>
|
void UpdateBackground(int oldCount, int newCount)
|
||||||
{
|
{
|
||||||
background.RemoveChildren();
|
background.RemoveChildren();
|
||||||
|
|
||||||
@@ -79,12 +78,12 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
bg.Bounds.Y = palette.IconSize.Y * y;
|
bg.Bounds.Y = palette.IconSize.Y * y;
|
||||||
background.AddChild(bg);
|
background.AddChild(bg);
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
palette.OnIconCountChanged += updateBackground;
|
palette.OnIconCountChanged += UpdateBackground;
|
||||||
|
|
||||||
// Set the initial palette state
|
// Set the initial palette state
|
||||||
updateBackground(0, 0);
|
UpdateBackground(0, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -46,20 +46,20 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
var originalTimestep = world.Timestep;
|
var originalTimestep = world.Timestep;
|
||||||
|
|
||||||
// In the event the replay goes out of sync, it becomes no longer usable. For polish we permanently pause the world.
|
// In the event the replay goes out of sync, it becomes no longer usable. For polish we permanently pause the world.
|
||||||
Func<bool> isWidgetDisabled = () => orderManager.IsOutOfSync || orderManager.NetFrameNumber >= replayNetTicks;
|
bool IsWidgetDisabled() => orderManager.IsOutOfSync || orderManager.NetFrameNumber >= replayNetTicks;
|
||||||
|
|
||||||
var pauseButton = widget.Get<ButtonWidget>("BUTTON_PAUSE");
|
var pauseButton = widget.Get<ButtonWidget>("BUTTON_PAUSE");
|
||||||
pauseButton.IsVisible = () => world.ReplayTimestep != 0 && !isWidgetDisabled();
|
pauseButton.IsVisible = () => world.ReplayTimestep != 0 && !IsWidgetDisabled();
|
||||||
pauseButton.OnClick = () => world.ReplayTimestep = 0;
|
pauseButton.OnClick = () => world.ReplayTimestep = 0;
|
||||||
|
|
||||||
var playButton = widget.Get<ButtonWidget>("BUTTON_PLAY");
|
var playButton = widget.Get<ButtonWidget>("BUTTON_PLAY");
|
||||||
playButton.IsVisible = () => world.ReplayTimestep == 0 || isWidgetDisabled();
|
playButton.IsVisible = () => world.ReplayTimestep == 0 || IsWidgetDisabled();
|
||||||
playButton.OnClick = () => world.ReplayTimestep = (int)Math.Ceiling(originalTimestep * multipliers[speed]);
|
playButton.OnClick = () => world.ReplayTimestep = (int)Math.Ceiling(originalTimestep * multipliers[speed]);
|
||||||
playButton.IsDisabled = isWidgetDisabled;
|
playButton.IsDisabled = IsWidgetDisabled;
|
||||||
|
|
||||||
var slowButton = widget.Get<ButtonWidget>("BUTTON_SLOW");
|
var slowButton = widget.Get<ButtonWidget>("BUTTON_SLOW");
|
||||||
slowButton.IsHighlighted = () => speed == PlaybackSpeed.Slow;
|
slowButton.IsHighlighted = () => speed == PlaybackSpeed.Slow;
|
||||||
slowButton.IsDisabled = isWidgetDisabled;
|
slowButton.IsDisabled = IsWidgetDisabled;
|
||||||
slowButton.OnClick = () =>
|
slowButton.OnClick = () =>
|
||||||
{
|
{
|
||||||
speed = PlaybackSpeed.Slow;
|
speed = PlaybackSpeed.Slow;
|
||||||
@@ -69,7 +69,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
|
|
||||||
var normalSpeedButton = widget.Get<ButtonWidget>("BUTTON_REGULAR");
|
var normalSpeedButton = widget.Get<ButtonWidget>("BUTTON_REGULAR");
|
||||||
normalSpeedButton.IsHighlighted = () => speed == PlaybackSpeed.Regular;
|
normalSpeedButton.IsHighlighted = () => speed == PlaybackSpeed.Regular;
|
||||||
normalSpeedButton.IsDisabled = isWidgetDisabled;
|
normalSpeedButton.IsDisabled = IsWidgetDisabled;
|
||||||
normalSpeedButton.OnClick = () =>
|
normalSpeedButton.OnClick = () =>
|
||||||
{
|
{
|
||||||
speed = PlaybackSpeed.Regular;
|
speed = PlaybackSpeed.Regular;
|
||||||
@@ -79,7 +79,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
|
|
||||||
var fastButton = widget.Get<ButtonWidget>("BUTTON_FAST");
|
var fastButton = widget.Get<ButtonWidget>("BUTTON_FAST");
|
||||||
fastButton.IsHighlighted = () => speed == PlaybackSpeed.Fast;
|
fastButton.IsHighlighted = () => speed == PlaybackSpeed.Fast;
|
||||||
fastButton.IsDisabled = isWidgetDisabled;
|
fastButton.IsDisabled = IsWidgetDisabled;
|
||||||
fastButton.OnClick = () =>
|
fastButton.OnClick = () =>
|
||||||
{
|
{
|
||||||
speed = PlaybackSpeed.Fast;
|
speed = PlaybackSpeed.Fast;
|
||||||
@@ -89,7 +89,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
|
|
||||||
var maximumButton = widget.Get<ButtonWidget>("BUTTON_MAXIMUM");
|
var maximumButton = widget.Get<ButtonWidget>("BUTTON_MAXIMUM");
|
||||||
maximumButton.IsHighlighted = () => speed == PlaybackSpeed.Maximum;
|
maximumButton.IsHighlighted = () => speed == PlaybackSpeed.Maximum;
|
||||||
maximumButton.IsDisabled = isWidgetDisabled;
|
maximumButton.IsDisabled = IsWidgetDisabled;
|
||||||
maximumButton.OnClick = () =>
|
maximumButton.OnClick = () =>
|
||||||
{
|
{
|
||||||
speed = PlaybackSpeed.Maximum;
|
speed = PlaybackSpeed.Maximum;
|
||||||
|
|||||||
@@ -9,7 +9,6 @@
|
|||||||
*/
|
*/
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
using System;
|
|
||||||
using OpenRA.Widgets;
|
using OpenRA.Widgets;
|
||||||
|
|
||||||
namespace OpenRA.Mods.Common.Widgets.Logic
|
namespace OpenRA.Mods.Common.Widgets.Logic
|
||||||
@@ -34,7 +33,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
if (foreground != null)
|
if (foreground != null)
|
||||||
foregroundTemplate = foreground.Get("ICON_TEMPLATE");
|
foregroundTemplate = foreground.Get("ICON_TEMPLATE");
|
||||||
|
|
||||||
Action<int, int> updateBackground = (_, icons) =>
|
void UpdateBackground(int _, int icons)
|
||||||
{
|
{
|
||||||
var rowHeight = palette.IconSize.Y + palette.IconMargin;
|
var rowHeight = palette.IconSize.Y + palette.IconMargin;
|
||||||
var rowWidth = palette.IconSize.X + palette.IconMargin;
|
var rowWidth = palette.IconSize.X + palette.IconMargin;
|
||||||
@@ -68,12 +67,12 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
foreground.AddChild(row);
|
foreground.AddChild(row);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
palette.OnIconCountChanged += updateBackground;
|
palette.OnIconCountChanged += UpdateBackground;
|
||||||
|
|
||||||
// Set the initial palette state
|
// Set the initial palette state
|
||||||
updateBackground(0, 0);
|
UpdateBackground(0, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -135,9 +135,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
progressBar.Percentage = progressPercentage;
|
progressBar.Percentage = progressPercentage;
|
||||||
}
|
}
|
||||||
|
|
||||||
Action<string> onExtractProgress = s => Game.RunAfterTick(() => getStatusText = () => s);
|
void OnExtractProgress(string s) => Game.RunAfterTick(() => getStatusText = () => s);
|
||||||
|
|
||||||
Action<string> onError = s => Game.RunAfterTick(() =>
|
void OnError(string s) => Game.RunAfterTick(() =>
|
||||||
{
|
{
|
||||||
var host = downloadHost ?? modData.Translation.GetString(UnknownHost);
|
var host = downloadHost ?? modData.Translation.GetString(UnknownHost);
|
||||||
Log.Write("install", $"Download from {host} failed: " + s);
|
Log.Write("install", $"Download from {host} failed: " + s);
|
||||||
@@ -149,7 +149,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
cancelButton.OnClick = Ui.CloseWindow;
|
cancelButton.OnClick = Ui.CloseWindow;
|
||||||
});
|
});
|
||||||
|
|
||||||
Action<string> downloadUrl = url =>
|
void DownloadUrl(string url)
|
||||||
{
|
{
|
||||||
Log.Write("install", "Downloading " + url);
|
Log.Write("install", "Downloading " + url);
|
||||||
|
|
||||||
@@ -205,7 +205,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
|
|
||||||
if (!archiveValid)
|
if (!archiveValid)
|
||||||
{
|
{
|
||||||
onError(modData.Translation.GetString(ArchiveValidationFailed));
|
OnError(modData.Translation.GetString(ArchiveValidationFailed));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -231,7 +231,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
onExtractProgress(modData.Translation.GetString(ExtractingEntry, Translation.Arguments("entry", kv.Value)));
|
OnExtractProgress(modData.Translation.GetString(ExtractingEntry, Translation.Arguments("entry", kv.Value)));
|
||||||
Log.Write("install", "Extracting " + kv.Value);
|
Log.Write("install", "Extracting " + kv.Value);
|
||||||
var targetPath = Platform.ResolvePath(kv.Key);
|
var targetPath = Platform.ResolvePath(kv.Key);
|
||||||
Directory.CreateDirectory(Path.GetDirectoryName(targetPath));
|
Directory.CreateDirectory(Path.GetDirectoryName(targetPath));
|
||||||
@@ -262,19 +262,19 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
File.Delete(f);
|
File.Delete(f);
|
||||||
}
|
}
|
||||||
|
|
||||||
onError(modData.Translation.GetString(ArchiveExtractionFailed));
|
OnError(modData.Translation.GetString(ArchiveExtractionFailed));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
onError(e.ToString());
|
OnError(e.ToString());
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
File.Delete(file);
|
File.Delete(file);
|
||||||
}
|
}
|
||||||
}, token);
|
}, token);
|
||||||
};
|
}
|
||||||
|
|
||||||
if (download.MirrorList != null)
|
if (download.MirrorList != null)
|
||||||
{
|
{
|
||||||
@@ -289,18 +289,18 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
var result = await httpResponseMessage.Content.ReadAsStringAsync();
|
var result = await httpResponseMessage.Content.ReadAsStringAsync();
|
||||||
|
|
||||||
var mirrorList = result.Split(new[] { '\n' }, StringSplitOptions.RemoveEmptyEntries);
|
var mirrorList = result.Split(new[] { '\n' }, StringSplitOptions.RemoveEmptyEntries);
|
||||||
downloadUrl(mirrorList.Random(new MersenneTwister()));
|
DownloadUrl(mirrorList.Random(new MersenneTwister()));
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Log.Write("install", "Mirror selection failed with error:");
|
Log.Write("install", "Mirror selection failed with error:");
|
||||||
Log.Write("install", e.ToString());
|
Log.Write("install", e.ToString());
|
||||||
onError(modData.Translation.GetString(MirrorSelectionFailed));
|
OnError(modData.Translation.GetString(MirrorSelectionFailed));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
downloadUrl(download.URL);
|
DownloadUrl(download.URL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -117,7 +117,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
// Show connection failed dialog
|
// Show connection failed dialog
|
||||||
Ui.CloseWindow();
|
Ui.CloseWindow();
|
||||||
|
|
||||||
Action onConnect = () =>
|
void OnConnect()
|
||||||
{
|
{
|
||||||
Game.OpenWindow("SERVER_LOBBY", new WidgetArgs()
|
Game.OpenWindow("SERVER_LOBBY", new WidgetArgs()
|
||||||
{
|
{
|
||||||
@@ -125,9 +125,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
{ "onStart", onStart },
|
{ "onStart", onStart },
|
||||||
{ "skirmishMode", false }
|
{ "skirmishMode", false }
|
||||||
});
|
});
|
||||||
};
|
}
|
||||||
|
|
||||||
Action<string> onRetry = pass => ConnectionLogic.Connect(connection.Target, pass, onConnect, onExit);
|
Action<string> onRetry = pass => ConnectionLogic.Connect(connection.Target, pass, OnConnect, onExit);
|
||||||
|
|
||||||
var switchPanel = CurrentServerSettings.ServerExternalMod != null ? "CONNECTION_SWITCHMOD_PANEL" : "CONNECTIONFAILED_PANEL";
|
var switchPanel = CurrentServerSettings.ServerExternalMod != null ? "CONNECTION_SWITCHMOD_PANEL" : "CONNECTIONFAILED_PANEL";
|
||||||
Ui.OpenWindow(switchPanel, new WidgetArgs()
|
Ui.OpenWindow(switchPanel, new WidgetArgs()
|
||||||
@@ -327,13 +327,14 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
options.Add(modData.Translation.GetString(ConfigureTeams), teamOptions);
|
options.Add(modData.Translation.GetString(ConfigureTeams), teamOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
Func<DropDownOption, ScrollItemWidget, ScrollItemWidget> setupItem = (option, template) =>
|
ScrollItemWidget SetupItem(DropDownOption option, ScrollItemWidget template)
|
||||||
{
|
{
|
||||||
var item = ScrollItemWidget.Setup(template, option.IsSelected, option.OnClick);
|
var item = ScrollItemWidget.Setup(template, option.IsSelected, option.OnClick);
|
||||||
item.Get<LabelWidget>("LABEL").GetText = () => option.Title;
|
item.Get<LabelWidget>("LABEL").GetText = () => option.Title;
|
||||||
return item;
|
return item;
|
||||||
};
|
}
|
||||||
slotsButton.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 175, options, setupItem);
|
|
||||||
|
slotsButton.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 175, options, SetupItem);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -401,7 +402,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Force start panel
|
// Force start panel
|
||||||
Action startGame = () =>
|
void StartGame()
|
||||||
{
|
{
|
||||||
// Refresh MapCache and check if the selected map is available before attempting to start the game
|
// Refresh MapCache and check if the selected map is available before attempting to start the game
|
||||||
if (modData.MapCache[map.Uid].Status == MapStatus.Available)
|
if (modData.MapCache[map.Uid].Status == MapStatus.Available)
|
||||||
@@ -411,7 +412,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
UpdateSelectedMap();
|
UpdateSelectedMap();
|
||||||
};
|
}
|
||||||
|
|
||||||
var startGameButton = lobby.GetOrNull<ButtonWidget>("START_GAME_BUTTON");
|
var startGameButton = lobby.GetOrNull<ButtonWidget>("START_GAME_BUTTON");
|
||||||
if (startGameButton != null)
|
if (startGameButton != null)
|
||||||
@@ -428,14 +429,14 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
if (orderManager.LobbyInfo.Clients.Any(c => c.Slot != null && !c.IsAdmin && c.Bot == null && !c.IsReady))
|
if (orderManager.LobbyInfo.Clients.Any(c => c.Slot != null && !c.IsAdmin && c.Bot == null && !c.IsReady))
|
||||||
panel = PanelType.ForceStart;
|
panel = PanelType.ForceStart;
|
||||||
else
|
else
|
||||||
startGame();
|
StartGame();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
var forceStartBin = Ui.LoadWidget("FORCE_START_DIALOG", lobby.Get("TOP_PANELS_ROOT"), new WidgetArgs());
|
var forceStartBin = Ui.LoadWidget("FORCE_START_DIALOG", lobby.Get("TOP_PANELS_ROOT"), new WidgetArgs());
|
||||||
forceStartBin.IsVisible = () => panel == PanelType.ForceStart;
|
forceStartBin.IsVisible = () => panel == PanelType.ForceStart;
|
||||||
forceStartBin.Get("KICK_WARNING").IsVisible = () => orderManager.LobbyInfo.Clients.Any(c => c.IsInvalid);
|
forceStartBin.Get("KICK_WARNING").IsVisible = () => orderManager.LobbyInfo.Clients.Any(c => c.IsInvalid);
|
||||||
forceStartBin.Get<ButtonWidget>("OK_BUTTON").OnClick = startGame;
|
forceStartBin.Get<ButtonWidget>("OK_BUTTON").OnClick = StartGame;
|
||||||
forceStartBin.Get<ButtonWidget>("CANCEL_BUTTON").OnClick = () => panel = PanelType.Players;
|
forceStartBin.Get<ButtonWidget>("CANCEL_BUTTON").OnClick = () => panel = PanelType.Players;
|
||||||
|
|
||||||
var disconnectButton = lobby.Get<ButtonWidget>("DISCONNECT_BUTTON");
|
var disconnectButton = lobby.Get<ButtonWidget>("DISCONNECT_BUTTON");
|
||||||
|
|||||||
@@ -157,17 +157,17 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
|
|
||||||
dropdown.OnMouseDown = _ =>
|
dropdown.OnMouseDown = _ =>
|
||||||
{
|
{
|
||||||
Func<KeyValuePair<string, string>, ScrollItemWidget, ScrollItemWidget> setupItem = (c, template) =>
|
ScrollItemWidget SetupItem(KeyValuePair<string, string> c, ScrollItemWidget template)
|
||||||
{
|
{
|
||||||
Func<bool> isSelected = () => optionValue.Update(orderManager.LobbyInfo.GlobalSettings).Value == c.Key;
|
bool IsSelected() => optionValue.Update(orderManager.LobbyInfo.GlobalSettings).Value == c.Key;
|
||||||
Action onClick = () => orderManager.IssueOrder(Order.Command($"option {option.Id} {c.Key}"));
|
void OnClick() => orderManager.IssueOrder(Order.Command($"option {option.Id} {c.Key}"));
|
||||||
|
|
||||||
var item = ScrollItemWidget.Setup(template, isSelected, onClick);
|
var item = ScrollItemWidget.Setup(template, IsSelected, OnClick);
|
||||||
item.Get<LabelWidget>("LABEL").GetText = () => c.Value;
|
item.Get<LabelWidget>("LABEL").GetText = () => c.Value;
|
||||||
return item;
|
return item;
|
||||||
};
|
}
|
||||||
|
|
||||||
dropdown.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", option.Values.Count * 30, option.Values, setupItem);
|
dropdown.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", option.Values.Count * 30, option.Values, SetupItem);
|
||||||
};
|
};
|
||||||
|
|
||||||
var label = row.GetOrNull<LabelWidget>(dropdown.Id + "_DESC");
|
var label = row.GetOrNull<LabelWidget>(dropdown.Id + "_DESC");
|
||||||
|
|||||||
@@ -82,16 +82,16 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
|
|
||||||
options.Add(bots.Count > 0 ? modData.Translation.GetString(Bots) : modData.Translation.GetString(BotsDisabled), bots);
|
options.Add(bots.Count > 0 ? modData.Translation.GetString(Bots) : modData.Translation.GetString(BotsDisabled), bots);
|
||||||
|
|
||||||
Func<SlotDropDownOption, ScrollItemWidget, ScrollItemWidget> setupItem = (o, itemTemplate) =>
|
ScrollItemWidget SetupItem(SlotDropDownOption o, ScrollItemWidget itemTemplate)
|
||||||
{
|
{
|
||||||
var item = ScrollItemWidget.Setup(itemTemplate,
|
var item = ScrollItemWidget.Setup(itemTemplate,
|
||||||
o.Selected,
|
o.Selected,
|
||||||
() => orderManager.IssueOrder(Order.Command(o.Order)));
|
() => orderManager.IssueOrder(Order.Command(o.Order)));
|
||||||
item.Get<LabelWidget>("LABEL").GetText = () => o.Title;
|
item.Get<LabelWidget>("LABEL").GetText = () => o.Title;
|
||||||
return item;
|
return item;
|
||||||
};
|
}
|
||||||
|
|
||||||
dropdown.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 180, options, setupItem);
|
dropdown.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 180, options, SetupItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void ShowPlayerActionDropDown(DropDownButtonWidget dropdown,
|
public static void ShowPlayerActionDropDown(DropDownButtonWidget dropdown,
|
||||||
@@ -137,37 +137,37 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Func<DropDownOption, ScrollItemWidget, ScrollItemWidget> setupItem = (o, itemTemplate) =>
|
ScrollItemWidget SetupItem(DropDownOption o, ScrollItemWidget itemTemplate)
|
||||||
{
|
{
|
||||||
var item = ScrollItemWidget.Setup(itemTemplate, o.IsSelected, o.OnClick);
|
var item = ScrollItemWidget.Setup(itemTemplate, o.IsSelected, o.OnClick);
|
||||||
var labelWidget = item.Get<LabelWidget>("LABEL");
|
var labelWidget = item.Get<LabelWidget>("LABEL");
|
||||||
labelWidget.GetText = () => o.Title;
|
labelWidget.GetText = () => o.Title;
|
||||||
return item;
|
return item;
|
||||||
};
|
}
|
||||||
|
|
||||||
dropdown.ShowDropDown("PLAYERACTION_DROPDOWN_TEMPLATE", 167, options, setupItem);
|
dropdown.ShowDropDown("PLAYERACTION_DROPDOWN_TEMPLATE", 167, options, SetupItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void ShowTeamDropDown(DropDownButtonWidget dropdown, Session.Client client,
|
public static void ShowTeamDropDown(DropDownButtonWidget dropdown, Session.Client client,
|
||||||
OrderManager orderManager, int teamCount)
|
OrderManager orderManager, int teamCount)
|
||||||
{
|
{
|
||||||
Func<int, ScrollItemWidget, ScrollItemWidget> setupItem = (ii, itemTemplate) =>
|
ScrollItemWidget SetupItem(int ii, ScrollItemWidget itemTemplate)
|
||||||
{
|
{
|
||||||
var item = ScrollItemWidget.Setup(itemTemplate,
|
var item = ScrollItemWidget.Setup(itemTemplate,
|
||||||
() => client.Team == ii,
|
() => client.Team == ii,
|
||||||
() => orderManager.IssueOrder(Order.Command($"team {client.Index} {ii}")));
|
() => orderManager.IssueOrder(Order.Command($"team {client.Index} {ii}")));
|
||||||
item.Get<LabelWidget>("LABEL").GetText = () => ii == 0 ? "-" : ii.ToString();
|
item.Get<LabelWidget>("LABEL").GetText = () => ii == 0 ? "-" : ii.ToString();
|
||||||
return item;
|
return item;
|
||||||
};
|
}
|
||||||
|
|
||||||
var options = Enumerable.Range(0, teamCount + 1);
|
var options = Enumerable.Range(0, teamCount + 1);
|
||||||
dropdown.ShowDropDown("TEAM_DROPDOWN_TEMPLATE", 150, options, setupItem);
|
dropdown.ShowDropDown("TEAM_DROPDOWN_TEMPLATE", 150, options, SetupItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void ShowHandicapDropDown(DropDownButtonWidget dropdown, Session.Client client,
|
public static void ShowHandicapDropDown(DropDownButtonWidget dropdown, Session.Client client,
|
||||||
OrderManager orderManager)
|
OrderManager orderManager)
|
||||||
{
|
{
|
||||||
Func<int, ScrollItemWidget, ScrollItemWidget> setupItem = (ii, itemTemplate) =>
|
ScrollItemWidget SetupItem(int ii, ScrollItemWidget itemTemplate)
|
||||||
{
|
{
|
||||||
var item = ScrollItemWidget.Setup(itemTemplate,
|
var item = ScrollItemWidget.Setup(itemTemplate,
|
||||||
() => client.Handicap == ii,
|
() => client.Handicap == ii,
|
||||||
@@ -176,26 +176,26 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
var label = $"{ii}%";
|
var label = $"{ii}%";
|
||||||
item.Get<LabelWidget>("LABEL").GetText = () => label;
|
item.Get<LabelWidget>("LABEL").GetText = () => label;
|
||||||
return item;
|
return item;
|
||||||
};
|
}
|
||||||
|
|
||||||
// Handicaps may be set between 0 - 95% in steps of 5%
|
// Handicaps may be set between 0 - 95% in steps of 5%
|
||||||
var options = Enumerable.Range(0, 20).Select(i => 5 * i);
|
var options = Enumerable.Range(0, 20).Select(i => 5 * i);
|
||||||
dropdown.ShowDropDown("TEAM_DROPDOWN_TEMPLATE", 150, options, setupItem);
|
dropdown.ShowDropDown("TEAM_DROPDOWN_TEMPLATE", 150, options, SetupItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void ShowSpawnDropDown(DropDownButtonWidget dropdown, Session.Client client,
|
public static void ShowSpawnDropDown(DropDownButtonWidget dropdown, Session.Client client,
|
||||||
OrderManager orderManager, IEnumerable<int> spawnPoints)
|
OrderManager orderManager, IEnumerable<int> spawnPoints)
|
||||||
{
|
{
|
||||||
Func<int, ScrollItemWidget, ScrollItemWidget> setupItem = (ii, itemTemplate) =>
|
ScrollItemWidget SetupItem(int ii, ScrollItemWidget itemTemplate)
|
||||||
{
|
{
|
||||||
var item = ScrollItemWidget.Setup(itemTemplate,
|
var item = ScrollItemWidget.Setup(itemTemplate,
|
||||||
() => client.SpawnPoint == ii,
|
() => client.SpawnPoint == ii,
|
||||||
() => SetSpawnPoint(orderManager, client, ii));
|
() => SetSpawnPoint(orderManager, client, ii));
|
||||||
item.Get<LabelWidget>("LABEL").GetText = () => ii == 0 ? "-" : Convert.ToChar('A' - 1 + ii).ToString();
|
item.Get<LabelWidget>("LABEL").GetText = () => ii == 0 ? "-" : Convert.ToChar('A' - 1 + ii).ToString();
|
||||||
return item;
|
return item;
|
||||||
};
|
}
|
||||||
|
|
||||||
dropdown.ShowDropDown("SPAWN_DROPDOWN_TEMPLATE", 150, spawnPoints, setupItem);
|
dropdown.ShowDropDown("SPAWN_DROPDOWN_TEMPLATE", 150, spawnPoints, SetupItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Splits a string into two parts on the first instance of a given token.</summary>
|
/// <summary>Splits a string into two parts on the first instance of a given token.</summary>
|
||||||
@@ -213,7 +213,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
public static void ShowFactionDropDown(DropDownButtonWidget dropdown, Session.Client client,
|
public static void ShowFactionDropDown(DropDownButtonWidget dropdown, Session.Client client,
|
||||||
OrderManager orderManager, Dictionary<string, LobbyFaction> factions)
|
OrderManager orderManager, Dictionary<string, LobbyFaction> factions)
|
||||||
{
|
{
|
||||||
Func<string, ScrollItemWidget, ScrollItemWidget> setupItem = (factionId, itemTemplate) =>
|
ScrollItemWidget SetupItem(string factionId, ScrollItemWidget itemTemplate)
|
||||||
{
|
{
|
||||||
var item = ScrollItemWidget.Setup(itemTemplate,
|
var item = ScrollItemWidget.Setup(itemTemplate,
|
||||||
() => client.Faction == factionId,
|
() => client.Faction == factionId,
|
||||||
@@ -233,18 +233,18 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
item.GetTooltipDesc = () => tooltip.Second;
|
item.GetTooltipDesc = () => tooltip.Second;
|
||||||
|
|
||||||
return item;
|
return item;
|
||||||
};
|
}
|
||||||
|
|
||||||
var options = factions.Where(f => f.Value.Selectable).GroupBy(f => f.Value.Side)
|
var options = factions.Where(f => f.Value.Selectable).GroupBy(f => f.Value.Side)
|
||||||
.ToDictionary(g => g.Key ?? "", g => g.Select(f => f.Key));
|
.ToDictionary(g => g.Key ?? "", g => g.Select(f => f.Key));
|
||||||
|
|
||||||
dropdown.ShowDropDown("FACTION_DROPDOWN_TEMPLATE", 154, options, setupItem);
|
dropdown.ShowDropDown("FACTION_DROPDOWN_TEMPLATE", 154, options, SetupItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void ShowColorDropDown(DropDownButtonWidget color, Session.Client client,
|
public static void ShowColorDropDown(DropDownButtonWidget color, Session.Client client,
|
||||||
OrderManager orderManager, WorldRenderer worldRenderer, ColorPickerManagerInfo colorManager)
|
OrderManager orderManager, WorldRenderer worldRenderer, ColorPickerManagerInfo colorManager)
|
||||||
{
|
{
|
||||||
Action onExit = () =>
|
void OnExit()
|
||||||
{
|
{
|
||||||
if (client == orderManager.LocalClient)
|
if (client == orderManager.LocalClient)
|
||||||
{
|
{
|
||||||
@@ -254,7 +254,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
|
|
||||||
color.RemovePanel();
|
color.RemovePanel();
|
||||||
orderManager.IssueOrder(Order.Command($"color {client.Index} {colorManager.Color}"));
|
orderManager.IssueOrder(Order.Command($"color {client.Index} {colorManager.Color}"));
|
||||||
};
|
}
|
||||||
|
|
||||||
var colorChooser = Game.LoadWidget(worldRenderer.World, "COLOR_CHOOSER", null, new WidgetArgs()
|
var colorChooser = Game.LoadWidget(worldRenderer.World, "COLOR_CHOOSER", null, new WidgetArgs()
|
||||||
{
|
{
|
||||||
@@ -263,7 +263,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
{ "initialFaction", client.Faction }
|
{ "initialFaction", client.Faction }
|
||||||
});
|
});
|
||||||
|
|
||||||
color.AttachPanel(colorChooser, onExit);
|
color.AttachPanel(colorChooser, OnExit);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void SelectSpawnPoint(OrderManager orderManager, MapPreviewWidget mapPreview, MapPreview preview, MouseInput mi)
|
public static void SelectSpawnPoint(OrderManager orderManager, MapPreviewWidget mapPreview, MapPreview preview, MouseInput mi)
|
||||||
@@ -511,7 +511,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
checkBox.IsVisible = () => orderManager.LocalClient.IsAdmin && !skirmishMode;
|
checkBox.IsVisible = () => orderManager.LocalClient.IsAdmin && !skirmishMode;
|
||||||
checkBox.IsDisabled = () => false;
|
checkBox.IsDisabled = () => false;
|
||||||
|
|
||||||
Action okPressed = () =>
|
void OkPressed()
|
||||||
{
|
{
|
||||||
orderManager.IssueOrder(Order.Command($"allow_spectators {!orderManager.LobbyInfo.GlobalSettings.AllowSpectators}"));
|
orderManager.IssueOrder(Order.Command($"allow_spectators {!orderManager.LobbyInfo.GlobalSettings.AllowSpectators}"));
|
||||||
orderManager.IssueOrders(
|
orderManager.IssueOrders(
|
||||||
@@ -520,7 +520,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
client => Order.Command($"kick {client.Index} {client.Name}")).ToArray());
|
client => Order.Command($"kick {client.Index} {client.Name}")).ToArray());
|
||||||
|
|
||||||
after();
|
after();
|
||||||
};
|
}
|
||||||
|
|
||||||
checkBox.OnClick = () =>
|
checkBox.OnClick = () =>
|
||||||
{
|
{
|
||||||
@@ -532,7 +532,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
Game.LoadWidget(null, "KICK_SPECTATORS_DIALOG", lobby.Get("TOP_PANELS_ROOT"), new WidgetArgs
|
Game.LoadWidget(null, "KICK_SPECTATORS_DIALOG", lobby.Get("TOP_PANELS_ROOT"), new WidgetArgs
|
||||||
{
|
{
|
||||||
{ "clientCount", spectatorCount },
|
{ "clientCount", spectatorCount },
|
||||||
{ "okPressed", okPressed },
|
{ "okPressed", OkPressed },
|
||||||
{ "cancelPressed", after }
|
{ "cancelPressed", after }
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -249,34 +249,34 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
|
|
||||||
menuType = MenuType.StartupPrompts;
|
menuType = MenuType.StartupPrompts;
|
||||||
|
|
||||||
Action onIntroductionComplete = () =>
|
void OnIntroductionComplete()
|
||||||
{
|
{
|
||||||
Action onSysInfoComplete = () =>
|
void OnSysInfoComplete()
|
||||||
{
|
{
|
||||||
LoadAndDisplayNews(webServices, newsBG);
|
LoadAndDisplayNews(webServices, newsBG);
|
||||||
SwitchMenu(MenuType.Main);
|
SwitchMenu(MenuType.Main);
|
||||||
};
|
}
|
||||||
|
|
||||||
if (SystemInfoPromptLogic.ShouldShowPrompt())
|
if (SystemInfoPromptLogic.ShouldShowPrompt())
|
||||||
{
|
{
|
||||||
Ui.OpenWindow("MAINMENU_SYSTEM_INFO_PROMPT", new WidgetArgs
|
Ui.OpenWindow("MAINMENU_SYSTEM_INFO_PROMPT", new WidgetArgs
|
||||||
{
|
{
|
||||||
{ "onComplete", onSysInfoComplete }
|
{ "onComplete", OnSysInfoComplete }
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
onSysInfoComplete();
|
OnSysInfoComplete();
|
||||||
};
|
}
|
||||||
|
|
||||||
if (IntroductionPromptLogic.ShouldShowPrompt())
|
if (IntroductionPromptLogic.ShouldShowPrompt())
|
||||||
{
|
{
|
||||||
Game.OpenWindow("MAINMENU_INTRODUCTION_PROMPT", new WidgetArgs
|
Game.OpenWindow("MAINMENU_INTRODUCTION_PROMPT", new WidgetArgs
|
||||||
{
|
{
|
||||||
{ "onComplete", onIntroductionComplete }
|
{ "onComplete", OnIntroductionComplete }
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
onIntroductionComplete();
|
OnIntroductionComplete();
|
||||||
|
|
||||||
Game.OnShellmapLoaded += OpenMenuBasedOnLastGame;
|
Game.OnShellmapLoaded += OpenMenuBasedOnLastGame;
|
||||||
|
|
||||||
|
|||||||
@@ -255,19 +255,19 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
// 'all game types' extra item
|
// 'all game types' extra item
|
||||||
categories.Insert(0, (null as string, tabMaps[tab].Length));
|
categories.Insert(0, (null as string, tabMaps[tab].Length));
|
||||||
|
|
||||||
Func<(string Category, int Count), string> showItem = x => (x.Category ?? allMaps) + $" ({x.Count})";
|
string ShowItem((string Category, int Count) x) => (x.Category ?? allMaps) + $" ({x.Count})";
|
||||||
|
|
||||||
Func<(string Category, int Count), ScrollItemWidget, ScrollItemWidget> setupItem = (ii, template) =>
|
ScrollItemWidget SetupItem((string Category, int Count) ii, ScrollItemWidget template)
|
||||||
{
|
{
|
||||||
var item = ScrollItemWidget.Setup(template,
|
var item = ScrollItemWidget.Setup(template,
|
||||||
() => category == ii.Category,
|
() => category == ii.Category,
|
||||||
() => { category = ii.Category; EnumerateMaps(tab, itemTemplate); });
|
() => { category = ii.Category; EnumerateMaps(tab, itemTemplate); });
|
||||||
item.Get<LabelWidget>("LABEL").GetText = () => showItem(ii);
|
item.Get<LabelWidget>("LABEL").GetText = () => ShowItem(ii);
|
||||||
return item;
|
return item;
|
||||||
};
|
}
|
||||||
|
|
||||||
gameModeDropdown.OnClick = () =>
|
gameModeDropdown.OnClick = () =>
|
||||||
gameModeDropdown.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 210, categories, setupItem);
|
gameModeDropdown.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 210, categories, SetupItem);
|
||||||
|
|
||||||
gameModeDropdown.GetText = () =>
|
gameModeDropdown.GetText = () =>
|
||||||
{
|
{
|
||||||
@@ -275,7 +275,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
if (item == default((string, int)))
|
if (item == default((string, int)))
|
||||||
item.Category = modData.Translation.GetString(NoMatches);
|
item.Category = modData.Translation.GetString(NoMatches);
|
||||||
|
|
||||||
return showItem(item);
|
return ShowItem(item);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -295,7 +295,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
if (orderByFunc == null)
|
if (orderByFunc == null)
|
||||||
orderByFunc = orderByDict[orderByPlayer];
|
orderByFunc = orderByDict[orderByPlayer];
|
||||||
|
|
||||||
Func<string, ScrollItemWidget, ScrollItemWidget> setupItem = (o, template) =>
|
ScrollItemWidget SetupItem(string o, ScrollItemWidget template)
|
||||||
{
|
{
|
||||||
var item = ScrollItemWidget.Setup(template,
|
var item = ScrollItemWidget.Setup(template,
|
||||||
() => orderByFunc == orderByDict[o],
|
() => orderByFunc == orderByDict[o],
|
||||||
@@ -303,10 +303,10 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
item.Get<LabelWidget>("LABEL").GetText = () => o;
|
item.Get<LabelWidget>("LABEL").GetText = () => o;
|
||||||
|
|
||||||
return item;
|
return item;
|
||||||
};
|
}
|
||||||
|
|
||||||
orderByDropdown.OnClick = () =>
|
orderByDropdown.OnClick = () =>
|
||||||
orderByDropdown.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 500, orderByDict.Keys, setupItem);
|
orderByDropdown.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 500, orderByDict.Keys, SetupItem);
|
||||||
|
|
||||||
orderByDropdown.GetText = () =>
|
orderByDropdown.GetText = () =>
|
||||||
orderByDict.FirstOrDefault(m => m.Value == orderByFunc).Key;
|
orderByDict.FirstOrDefault(m => m.Value == orderByFunc).Key;
|
||||||
@@ -334,17 +334,17 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
// Access the minimap to trigger async generation of the minimap.
|
// Access the minimap to trigger async generation of the minimap.
|
||||||
preview.GetMinimap();
|
preview.GetMinimap();
|
||||||
|
|
||||||
Action dblClick = () =>
|
void DblClick()
|
||||||
{
|
{
|
||||||
if (onSelect != null)
|
if (onSelect != null)
|
||||||
{
|
{
|
||||||
Ui.CloseWindow();
|
Ui.CloseWindow();
|
||||||
onSelect(preview.Uid);
|
onSelect(preview.Uid);
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
var item = ScrollItemWidget.Setup(preview.Uid, template, () => selectedUid == preview.Uid,
|
var item = ScrollItemWidget.Setup(preview.Uid, template, () => selectedUid == preview.Uid,
|
||||||
() => selectedUid = preview.Uid, dblClick);
|
() => selectedUid = preview.Uid, DblClick);
|
||||||
item.IsVisible = () => item.RenderBounds.IntersectsWith(scrollpanels[tab].RenderBounds);
|
item.IsVisible = () => item.RenderBounds.IntersectsWith(scrollpanels[tab].RenderBounds);
|
||||||
|
|
||||||
var titleLabel = item.Get<LabelWithTooltipWidget>("TITLE");
|
var titleLabel = item.Get<LabelWithTooltipWidget>("TITLE");
|
||||||
|
|||||||
@@ -298,14 +298,14 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
OnClick = () => difficulty = kv.Key
|
OnClick = () => difficulty = kv.Key
|
||||||
});
|
});
|
||||||
|
|
||||||
Func<DropDownOption, ScrollItemWidget, ScrollItemWidget> setupItem = (option, template) =>
|
ScrollItemWidget SetupItem(DropDownOption option, ScrollItemWidget template)
|
||||||
{
|
{
|
||||||
var item = ScrollItemWidget.Setup(template, option.IsSelected, option.OnClick);
|
var item = ScrollItemWidget.Setup(template, option.IsSelected, option.OnClick);
|
||||||
item.Get<LabelWidget>("LABEL").GetText = () => option.Title;
|
item.Get<LabelWidget>("LABEL").GetText = () => option.Title;
|
||||||
return item;
|
return item;
|
||||||
};
|
}
|
||||||
|
|
||||||
difficultyButton.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", options.Count() * 30, options, setupItem);
|
difficultyButton.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", options.Count() * 30, options, SetupItem);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -325,14 +325,14 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
OnClick = () => gameSpeed = s.Key
|
OnClick = () => gameSpeed = s.Key
|
||||||
});
|
});
|
||||||
|
|
||||||
Func<DropDownOption, ScrollItemWidget, ScrollItemWidget> setupItem = (option, template) =>
|
ScrollItemWidget SetupItem(DropDownOption option, ScrollItemWidget template)
|
||||||
{
|
{
|
||||||
var item = ScrollItemWidget.Setup(template, option.IsSelected, option.OnClick);
|
var item = ScrollItemWidget.Setup(template, option.IsSelected, option.OnClick);
|
||||||
item.Get<LabelWidget>("LABEL").GetText = () => option.Title;
|
item.Get<LabelWidget>("LABEL").GetText = () => option.Title;
|
||||||
return item;
|
return item;
|
||||||
};
|
}
|
||||||
|
|
||||||
gameSpeedButton.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", options.Count() * 30, options, setupItem);
|
gameSpeedButton.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", options.Count() * 30, options, SetupItem);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
// Close the multiplayer browser
|
// Close the multiplayer browser
|
||||||
Ui.CloseWindow();
|
Ui.CloseWindow();
|
||||||
|
|
||||||
Action onLobbyExit = () =>
|
void OnLobbyExit()
|
||||||
{
|
{
|
||||||
// Open a fresh copy of the multiplayer browser
|
// Open a fresh copy of the multiplayer browser
|
||||||
Ui.OpenWindow("MULTIPLAYER_PANEL", new WidgetArgs
|
Ui.OpenWindow("MULTIPLAYER_PANEL", new WidgetArgs
|
||||||
@@ -97,12 +97,12 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
Game.Disconnect();
|
Game.Disconnect();
|
||||||
|
|
||||||
DiscordService.UpdateStatus(DiscordState.InMenu);
|
DiscordService.UpdateStatus(DiscordState.InMenu);
|
||||||
};
|
}
|
||||||
|
|
||||||
Game.OpenWindow("SERVER_LOBBY", new WidgetArgs
|
Game.OpenWindow("SERVER_LOBBY", new WidgetArgs
|
||||||
{
|
{
|
||||||
{ "onStart", onStart },
|
{ "onStart", onStart },
|
||||||
{ "onExit", onLobbyExit },
|
{ "onExit", OnLobbyExit },
|
||||||
{ "skirmishMode", false }
|
{ "skirmishMode", false }
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
|
|
||||||
BuildMusicTable();
|
BuildMusicTable();
|
||||||
|
|
||||||
Func<bool> noMusic = () => !musicPlaylist.IsMusicAvailable || musicPlaylist.CurrentSongIsBackground || currentSong == null;
|
bool NoMusic() => !musicPlaylist.IsMusicAvailable || musicPlaylist.CurrentSongIsBackground || currentSong == null;
|
||||||
panel.Get("NO_MUSIC_LABEL").IsVisible = () => !musicPlaylist.IsMusicAvailable;
|
panel.Get("NO_MUSIC_LABEL").IsVisible = () => !musicPlaylist.IsMusicAvailable;
|
||||||
|
|
||||||
if (musicPlaylist.IsMusicAvailable)
|
if (musicPlaylist.IsMusicAvailable)
|
||||||
@@ -57,25 +57,25 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
|
|
||||||
var playButton = panel.Get<ButtonWidget>("BUTTON_PLAY");
|
var playButton = panel.Get<ButtonWidget>("BUTTON_PLAY");
|
||||||
playButton.OnClick = Play;
|
playButton.OnClick = Play;
|
||||||
playButton.IsDisabled = noMusic;
|
playButton.IsDisabled = NoMusic;
|
||||||
playButton.IsVisible = () => !Game.Sound.MusicPlaying;
|
playButton.IsVisible = () => !Game.Sound.MusicPlaying;
|
||||||
|
|
||||||
var pauseButton = panel.Get<ButtonWidget>("BUTTON_PAUSE");
|
var pauseButton = panel.Get<ButtonWidget>("BUTTON_PAUSE");
|
||||||
pauseButton.OnClick = Game.Sound.PauseMusic;
|
pauseButton.OnClick = Game.Sound.PauseMusic;
|
||||||
pauseButton.IsDisabled = noMusic;
|
pauseButton.IsDisabled = NoMusic;
|
||||||
pauseButton.IsVisible = () => Game.Sound.MusicPlaying;
|
pauseButton.IsVisible = () => Game.Sound.MusicPlaying;
|
||||||
|
|
||||||
var stopButton = panel.Get<ButtonWidget>("BUTTON_STOP");
|
var stopButton = panel.Get<ButtonWidget>("BUTTON_STOP");
|
||||||
stopButton.OnClick = () => { musicPlaylist.Stop(); };
|
stopButton.OnClick = () => { musicPlaylist.Stop(); };
|
||||||
stopButton.IsDisabled = noMusic;
|
stopButton.IsDisabled = NoMusic;
|
||||||
|
|
||||||
var nextButton = panel.Get<ButtonWidget>("BUTTON_NEXT");
|
var nextButton = panel.Get<ButtonWidget>("BUTTON_NEXT");
|
||||||
nextButton.OnClick = () => { currentSong = musicPlaylist.GetNextSong(); Play(); };
|
nextButton.OnClick = () => { currentSong = musicPlaylist.GetNextSong(); Play(); };
|
||||||
nextButton.IsDisabled = noMusic;
|
nextButton.IsDisabled = NoMusic;
|
||||||
|
|
||||||
var prevButton = panel.Get<ButtonWidget>("BUTTON_PREV");
|
var prevButton = panel.Get<ButtonWidget>("BUTTON_PREV");
|
||||||
prevButton.OnClick = () => { currentSong = musicPlaylist.GetPrevSong(); Play(); };
|
prevButton.OnClick = () => { currentSong = musicPlaylist.GetPrevSong(); Play(); };
|
||||||
prevButton.IsDisabled = noMusic;
|
prevButton.IsDisabled = NoMusic;
|
||||||
|
|
||||||
var shuffleCheckbox = panel.Get<CheckboxWidget>("SHUFFLE");
|
var shuffleCheckbox = panel.Get<CheckboxWidget>("SHUFFLE");
|
||||||
shuffleCheckbox.IsChecked = () => Game.Settings.Sound.Shuffle;
|
shuffleCheckbox.IsChecked = () => Game.Settings.Sound.Shuffle;
|
||||||
|
|||||||
@@ -240,7 +240,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
ddb.GetText = () => lookup[filter.Type];
|
ddb.GetText = () => lookup[filter.Type];
|
||||||
ddb.OnMouseDown = _ =>
|
ddb.OnMouseDown = _ =>
|
||||||
{
|
{
|
||||||
Func<(GameType GameType, string Text), ScrollItemWidget, ScrollItemWidget> setupItem = (option, tpl) =>
|
ScrollItemWidget SetupItem((GameType GameType, string Text) option, ScrollItemWidget tpl)
|
||||||
{
|
{
|
||||||
var item = ScrollItemWidget.Setup(
|
var item = ScrollItemWidget.Setup(
|
||||||
tpl,
|
tpl,
|
||||||
@@ -248,9 +248,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
() => { filter.Type = option.GameType; ApplyFilter(); });
|
() => { filter.Type = option.GameType; ApplyFilter(); });
|
||||||
item.Get<LabelWidget>("LABEL").GetText = () => option.Text;
|
item.Get<LabelWidget>("LABEL").GetText = () => option.Text;
|
||||||
return item;
|
return item;
|
||||||
};
|
}
|
||||||
|
|
||||||
ddb.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 330, options, setupItem);
|
ddb.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 330, options, SetupItem);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -275,7 +275,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
ddb.GetText = () => lookup[filter.Date];
|
ddb.GetText = () => lookup[filter.Date];
|
||||||
ddb.OnMouseDown = _ =>
|
ddb.OnMouseDown = _ =>
|
||||||
{
|
{
|
||||||
Func<(DateType DateType, string Text), ScrollItemWidget, ScrollItemWidget> setupItem = (option, tpl) =>
|
ScrollItemWidget SetupItem((DateType DateType, string Text) option, ScrollItemWidget tpl)
|
||||||
{
|
{
|
||||||
var item = ScrollItemWidget.Setup(
|
var item = ScrollItemWidget.Setup(
|
||||||
tpl,
|
tpl,
|
||||||
@@ -284,9 +284,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
|
|
||||||
item.Get<LabelWidget>("LABEL").GetText = () => option.Text;
|
item.Get<LabelWidget>("LABEL").GetText = () => option.Text;
|
||||||
return item;
|
return item;
|
||||||
};
|
}
|
||||||
|
|
||||||
ddb.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 330, options, setupItem);
|
ddb.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 330, options, SetupItem);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -311,7 +311,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
ddb.GetText = () => lookup[filter.Duration];
|
ddb.GetText = () => lookup[filter.Duration];
|
||||||
ddb.OnMouseDown = _ =>
|
ddb.OnMouseDown = _ =>
|
||||||
{
|
{
|
||||||
Func<(DurationType DurationType, string Text), ScrollItemWidget, ScrollItemWidget> setupItem = (option, tpl) =>
|
ScrollItemWidget SetupItem((DurationType DurationType, string Text) option, ScrollItemWidget tpl)
|
||||||
{
|
{
|
||||||
var item = ScrollItemWidget.Setup(
|
var item = ScrollItemWidget.Setup(
|
||||||
tpl,
|
tpl,
|
||||||
@@ -319,9 +319,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
() => { filter.Duration = option.DurationType; ApplyFilter(); });
|
() => { filter.Duration = option.DurationType; ApplyFilter(); });
|
||||||
item.Get<LabelWidget>("LABEL").GetText = () => option.Text;
|
item.Get<LabelWidget>("LABEL").GetText = () => option.Text;
|
||||||
return item;
|
return item;
|
||||||
};
|
}
|
||||||
|
|
||||||
ddb.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 330, options, setupItem);
|
ddb.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 330, options, SetupItem);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -346,7 +346,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
ddb.GetText = () => lookup[filter.Outcome];
|
ddb.GetText = () => lookup[filter.Outcome];
|
||||||
ddb.OnMouseDown = _ =>
|
ddb.OnMouseDown = _ =>
|
||||||
{
|
{
|
||||||
Func<(WinState WinState, string Text), ScrollItemWidget, ScrollItemWidget> setupItem = (option, tpl) =>
|
ScrollItemWidget SetupItem((WinState WinState, string Text) option, ScrollItemWidget tpl)
|
||||||
{
|
{
|
||||||
var item = ScrollItemWidget.Setup(
|
var item = ScrollItemWidget.Setup(
|
||||||
tpl,
|
tpl,
|
||||||
@@ -354,9 +354,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
() => { filter.Outcome = option.WinState; ApplyFilter(); });
|
() => { filter.Outcome = option.WinState; ApplyFilter(); });
|
||||||
item.Get<LabelWidget>("LABEL").GetText = () => option.Text;
|
item.Get<LabelWidget>("LABEL").GetText = () => option.Text;
|
||||||
return item;
|
return item;
|
||||||
};
|
}
|
||||||
|
|
||||||
ddb.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 330, options, setupItem);
|
ddb.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 330, options, SetupItem);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -384,7 +384,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
ddb.GetText = () => string.IsNullOrEmpty(filter.MapName) ? anyText : filter.MapName;
|
ddb.GetText = () => string.IsNullOrEmpty(filter.MapName) ? anyText : filter.MapName;
|
||||||
ddb.OnMouseDown = _ =>
|
ddb.OnMouseDown = _ =>
|
||||||
{
|
{
|
||||||
Func<string, ScrollItemWidget, ScrollItemWidget> setupItem = (option, tpl) =>
|
ScrollItemWidget SetupItem(string option, ScrollItemWidget tpl)
|
||||||
{
|
{
|
||||||
var item = ScrollItemWidget.Setup(
|
var item = ScrollItemWidget.Setup(
|
||||||
tpl,
|
tpl,
|
||||||
@@ -392,9 +392,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
() => { filter.MapName = option; ApplyFilter(); });
|
() => { filter.MapName = option; ApplyFilter(); });
|
||||||
item.Get<LabelWidget>("LABEL").GetText = () => option ?? anyText;
|
item.Get<LabelWidget>("LABEL").GetText = () => option ?? anyText;
|
||||||
return item;
|
return item;
|
||||||
};
|
}
|
||||||
|
|
||||||
ddb.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 330, options, setupItem);
|
ddb.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 330, options, SetupItem);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -412,7 +412,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
ddb.GetText = () => string.IsNullOrEmpty(filter.PlayerName) ? anyText : filter.PlayerName;
|
ddb.GetText = () => string.IsNullOrEmpty(filter.PlayerName) ? anyText : filter.PlayerName;
|
||||||
ddb.OnMouseDown = _ =>
|
ddb.OnMouseDown = _ =>
|
||||||
{
|
{
|
||||||
Func<string, ScrollItemWidget, ScrollItemWidget> setupItem = (option, tpl) =>
|
ScrollItemWidget SetupItem(string option, ScrollItemWidget tpl)
|
||||||
{
|
{
|
||||||
var item = ScrollItemWidget.Setup(
|
var item = ScrollItemWidget.Setup(
|
||||||
tpl,
|
tpl,
|
||||||
@@ -420,9 +420,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
() => { filter.PlayerName = option; ApplyFilter(); });
|
() => { filter.PlayerName = option; ApplyFilter(); });
|
||||||
item.Get<LabelWidget>("LABEL").GetText = () => option ?? anyText;
|
item.Get<LabelWidget>("LABEL").GetText = () => option ?? anyText;
|
||||||
return item;
|
return item;
|
||||||
};
|
}
|
||||||
|
|
||||||
ddb.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 330, options, setupItem);
|
ddb.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 330, options, SetupItem);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -444,7 +444,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
ddb.GetText = () => string.IsNullOrEmpty(filter.Faction) ? anyText : filter.Faction;
|
ddb.GetText = () => string.IsNullOrEmpty(filter.Faction) ? anyText : filter.Faction;
|
||||||
ddb.OnMouseDown = _ =>
|
ddb.OnMouseDown = _ =>
|
||||||
{
|
{
|
||||||
Func<string, ScrollItemWidget, ScrollItemWidget> setupItem = (option, tpl) =>
|
ScrollItemWidget SetupItem(string option, ScrollItemWidget tpl)
|
||||||
{
|
{
|
||||||
var item = ScrollItemWidget.Setup(
|
var item = ScrollItemWidget.Setup(
|
||||||
tpl,
|
tpl,
|
||||||
@@ -452,9 +452,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
() => { filter.Faction = option; ApplyFilter(); });
|
() => { filter.Faction = option; ApplyFilter(); });
|
||||||
item.Get<LabelWidget>("LABEL").GetText = () => option ?? anyText;
|
item.Get<LabelWidget>("LABEL").GetText = () => option ?? anyText;
|
||||||
return item;
|
return item;
|
||||||
};
|
}
|
||||||
|
|
||||||
ddb.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 330, options, setupItem);
|
ddb.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 330, options, SetupItem);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -497,7 +497,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
Action<ReplayMetadata, Action> onDeleteReplay = (r, after) =>
|
void OnDeleteReplay(ReplayMetadata r, Action after)
|
||||||
{
|
{
|
||||||
ConfirmationDialogs.ButtonPrompt(modData,
|
ConfirmationDialogs.ButtonPrompt(modData,
|
||||||
title: DeleteReplayTitle,
|
title: DeleteReplayTitle,
|
||||||
@@ -510,13 +510,13 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
},
|
},
|
||||||
confirmText: DeleteReplayAccept,
|
confirmText: DeleteReplayAccept,
|
||||||
onCancel: () => { });
|
onCancel: () => { });
|
||||||
};
|
}
|
||||||
|
|
||||||
var deleteButton = panel.Get<ButtonWidget>("MNG_DELSEL_BUTTON");
|
var deleteButton = panel.Get<ButtonWidget>("MNG_DELSEL_BUTTON");
|
||||||
deleteButton.IsDisabled = () => selectedReplay == null;
|
deleteButton.IsDisabled = () => selectedReplay == null;
|
||||||
deleteButton.OnClick = () =>
|
deleteButton.OnClick = () =>
|
||||||
{
|
{
|
||||||
onDeleteReplay(selectedReplay, () =>
|
OnDeleteReplay(selectedReplay, () =>
|
||||||
{
|
{
|
||||||
if (selectedReplay == null)
|
if (selectedReplay == null)
|
||||||
SelectFirstVisibleReplay();
|
SelectFirstVisibleReplay();
|
||||||
@@ -533,7 +533,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
|
|
||||||
if (list.Count == 1)
|
if (list.Count == 1)
|
||||||
{
|
{
|
||||||
onDeleteReplay(list[0], () => { if (selectedReplay == null) SelectFirstVisibleReplay(); });
|
OnDeleteReplay(list[0], () => { if (selectedReplay == null) SelectFirstVisibleReplay(); });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -231,12 +231,12 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
progressText.GetText = ProgressLabelText;
|
progressText.GetText = ProgressLabelText;
|
||||||
|
|
||||||
var gs = Game.Settings.Game;
|
var gs = Game.Settings.Game;
|
||||||
Action<MPGameFilters> toggleFilterFlag = f =>
|
void ToggleFilterFlag(MPGameFilters f)
|
||||||
{
|
{
|
||||||
gs.MPGameFilters ^= f;
|
gs.MPGameFilters ^= f;
|
||||||
Game.Settings.Save();
|
Game.Settings.Save();
|
||||||
RefreshServerList();
|
RefreshServerList();
|
||||||
};
|
}
|
||||||
|
|
||||||
var filtersButton = widget.GetOrNull<DropDownButtonWidget>("FILTERS_DROPDOWNBUTTON");
|
var filtersButton = widget.GetOrNull<DropDownButtonWidget>("FILTERS_DROPDOWNBUTTON");
|
||||||
if (filtersButton != null)
|
if (filtersButton != null)
|
||||||
@@ -251,35 +251,35 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
if (showWaitingCheckbox != null)
|
if (showWaitingCheckbox != null)
|
||||||
{
|
{
|
||||||
showWaitingCheckbox.IsChecked = () => gs.MPGameFilters.HasFlag(MPGameFilters.Waiting);
|
showWaitingCheckbox.IsChecked = () => gs.MPGameFilters.HasFlag(MPGameFilters.Waiting);
|
||||||
showWaitingCheckbox.OnClick = () => toggleFilterFlag(MPGameFilters.Waiting);
|
showWaitingCheckbox.OnClick = () => ToggleFilterFlag(MPGameFilters.Waiting);
|
||||||
}
|
}
|
||||||
|
|
||||||
var showEmptyCheckbox = filtersPanel.GetOrNull<CheckboxWidget>("EMPTY");
|
var showEmptyCheckbox = filtersPanel.GetOrNull<CheckboxWidget>("EMPTY");
|
||||||
if (showEmptyCheckbox != null)
|
if (showEmptyCheckbox != null)
|
||||||
{
|
{
|
||||||
showEmptyCheckbox.IsChecked = () => gs.MPGameFilters.HasFlag(MPGameFilters.Empty);
|
showEmptyCheckbox.IsChecked = () => gs.MPGameFilters.HasFlag(MPGameFilters.Empty);
|
||||||
showEmptyCheckbox.OnClick = () => toggleFilterFlag(MPGameFilters.Empty);
|
showEmptyCheckbox.OnClick = () => ToggleFilterFlag(MPGameFilters.Empty);
|
||||||
}
|
}
|
||||||
|
|
||||||
var showAlreadyStartedCheckbox = filtersPanel.GetOrNull<CheckboxWidget>("ALREADY_STARTED");
|
var showAlreadyStartedCheckbox = filtersPanel.GetOrNull<CheckboxWidget>("ALREADY_STARTED");
|
||||||
if (showAlreadyStartedCheckbox != null)
|
if (showAlreadyStartedCheckbox != null)
|
||||||
{
|
{
|
||||||
showAlreadyStartedCheckbox.IsChecked = () => gs.MPGameFilters.HasFlag(MPGameFilters.Started);
|
showAlreadyStartedCheckbox.IsChecked = () => gs.MPGameFilters.HasFlag(MPGameFilters.Started);
|
||||||
showAlreadyStartedCheckbox.OnClick = () => toggleFilterFlag(MPGameFilters.Started);
|
showAlreadyStartedCheckbox.OnClick = () => ToggleFilterFlag(MPGameFilters.Started);
|
||||||
}
|
}
|
||||||
|
|
||||||
var showProtectedCheckbox = filtersPanel.GetOrNull<CheckboxWidget>("PASSWORD_PROTECTED");
|
var showProtectedCheckbox = filtersPanel.GetOrNull<CheckboxWidget>("PASSWORD_PROTECTED");
|
||||||
if (showProtectedCheckbox != null)
|
if (showProtectedCheckbox != null)
|
||||||
{
|
{
|
||||||
showProtectedCheckbox.IsChecked = () => gs.MPGameFilters.HasFlag(MPGameFilters.Protected);
|
showProtectedCheckbox.IsChecked = () => gs.MPGameFilters.HasFlag(MPGameFilters.Protected);
|
||||||
showProtectedCheckbox.OnClick = () => toggleFilterFlag(MPGameFilters.Protected);
|
showProtectedCheckbox.OnClick = () => ToggleFilterFlag(MPGameFilters.Protected);
|
||||||
}
|
}
|
||||||
|
|
||||||
var showIncompatibleCheckbox = filtersPanel.GetOrNull<CheckboxWidget>("INCOMPATIBLE_VERSION");
|
var showIncompatibleCheckbox = filtersPanel.GetOrNull<CheckboxWidget>("INCOMPATIBLE_VERSION");
|
||||||
if (showIncompatibleCheckbox != null)
|
if (showIncompatibleCheckbox != null)
|
||||||
{
|
{
|
||||||
showIncompatibleCheckbox.IsChecked = () => gs.MPGameFilters.HasFlag(MPGameFilters.Incompatible);
|
showIncompatibleCheckbox.IsChecked = () => gs.MPGameFilters.HasFlag(MPGameFilters.Incompatible);
|
||||||
showIncompatibleCheckbox.OnClick = () => toggleFilterFlag(MPGameFilters.Incompatible);
|
showIncompatibleCheckbox.OnClick = () => ToggleFilterFlag(MPGameFilters.Incompatible);
|
||||||
}
|
}
|
||||||
|
|
||||||
filtersButton.IsDisabled = () => searchStatus == SearchStatus.Fetching;
|
filtersButton.IsDisabled = () => searchStatus == SearchStatus.Fetching;
|
||||||
@@ -692,7 +692,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
header.Get<LabelWidget>("LABEL").GetText = () => headerTitle;
|
header.Get<LabelWidget>("LABEL").GetText = () => headerTitle;
|
||||||
rows.Add(header);
|
rows.Add(header);
|
||||||
|
|
||||||
Func<GameServer, int> listOrder = g =>
|
int ListOrder(GameServer g)
|
||||||
{
|
{
|
||||||
// Servers waiting for players are always first
|
// Servers waiting for players are always first
|
||||||
if (g.State == (int)ServerState.WaitingPlayers && g.Players > 0)
|
if (g.State == (int)ServerState.WaitingPlayers && g.Players > 0)
|
||||||
@@ -709,9 +709,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
// Empty servers are shown at the end because a flood of empty servers
|
// Empty servers are shown at the end because a flood of empty servers
|
||||||
// at the top of the game list make the community look dead
|
// at the top of the game list make the community look dead
|
||||||
return 3;
|
return 3;
|
||||||
};
|
}
|
||||||
|
|
||||||
foreach (var modGamesByState in modGames.GroupBy(listOrder).OrderBy(g => g.Key))
|
foreach (var modGamesByState in modGames.GroupBy(ListOrder).OrderBy(g => g.Key))
|
||||||
{
|
{
|
||||||
// Sort 'Playing' games by Started, others by number of players
|
// Sort 'Playing' games by Started, others by number of players
|
||||||
foreach (var game in modGamesByState.Key == 2 ? modGamesByState.OrderByDescending(g => g.Started) : modGamesByState.OrderByDescending(g => g.Players))
|
foreach (var game in modGamesByState.Key == 2 ? modGamesByState.OrderByDescending(g => g.Started) : modGamesByState.OrderByDescending(g => g.Players))
|
||||||
|
|||||||
@@ -156,7 +156,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
var i = 0;
|
var i = 0;
|
||||||
var options = devices.ToDictionary(d => i++.ToString(), d => d);
|
var options = devices.ToDictionary(d => i++.ToString(), d => d);
|
||||||
|
|
||||||
Func<string, ScrollItemWidget, ScrollItemWidget> setupItem = (o, itemTemplate) =>
|
ScrollItemWidget SetupItem(string o, ScrollItemWidget itemTemplate)
|
||||||
{
|
{
|
||||||
var item = ScrollItemWidget.Setup(itemTemplate,
|
var item = ScrollItemWidget.Setup(itemTemplate,
|
||||||
() => soundDevice == options[o],
|
() => soundDevice == options[o],
|
||||||
@@ -171,9 +171,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
var label = WidgetUtils.TruncateText(options[o].Label, deviceLabel.Bounds.Width, font);
|
var label = WidgetUtils.TruncateText(options[o].Label, deviceLabel.Bounds.Width, font);
|
||||||
deviceLabel.GetText = () => label;
|
deviceLabel.GetText = () => label;
|
||||||
return item;
|
return item;
|
||||||
};
|
}
|
||||||
|
|
||||||
dropdown.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 500, options.Keys, setupItem);
|
dropdown.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 500, options.Keys, SetupItem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -342,7 +342,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
{ modData.Translation.GetString(Windowed), WindowMode.Windowed },
|
{ modData.Translation.GetString(Windowed), WindowMode.Windowed },
|
||||||
};
|
};
|
||||||
|
|
||||||
Func<string, ScrollItemWidget, ScrollItemWidget> setupItem = (o, itemTemplate) =>
|
ScrollItemWidget SetupItem(string o, ScrollItemWidget itemTemplate)
|
||||||
{
|
{
|
||||||
var item = ScrollItemWidget.Setup(itemTemplate,
|
var item = ScrollItemWidget.Setup(itemTemplate,
|
||||||
() => s.Mode == options[o],
|
() => s.Mode == options[o],
|
||||||
@@ -354,31 +354,31 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
|
|
||||||
item.Get<LabelWidget>("LABEL").GetText = () => o;
|
item.Get<LabelWidget>("LABEL").GetText = () => o;
|
||||||
return item;
|
return item;
|
||||||
};
|
}
|
||||||
|
|
||||||
dropdown.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 500, options.Keys, setupItem);
|
dropdown.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 500, options.Keys, SetupItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void BindTextNotificationPoolFilterSettings(Widget panel, GameSettings gs)
|
public static void BindTextNotificationPoolFilterSettings(Widget panel, GameSettings gs)
|
||||||
{
|
{
|
||||||
Action<TextNotificationPoolFilters> toggleFilterFlag = f =>
|
void ToggleFilterFlag(TextNotificationPoolFilters f)
|
||||||
{
|
{
|
||||||
gs.TextNotificationPoolFilters ^= f;
|
gs.TextNotificationPoolFilters ^= f;
|
||||||
Game.Settings.Save();
|
Game.Settings.Save();
|
||||||
};
|
}
|
||||||
|
|
||||||
var feedbackCheckbox = panel.GetOrNull<CheckboxWidget>("UI_FEEDBACK_CHECKBOX");
|
var feedbackCheckbox = panel.GetOrNull<CheckboxWidget>("UI_FEEDBACK_CHECKBOX");
|
||||||
if (feedbackCheckbox != null)
|
if (feedbackCheckbox != null)
|
||||||
{
|
{
|
||||||
feedbackCheckbox.IsChecked = () => gs.TextNotificationPoolFilters.HasFlag(TextNotificationPoolFilters.Feedback);
|
feedbackCheckbox.IsChecked = () => gs.TextNotificationPoolFilters.HasFlag(TextNotificationPoolFilters.Feedback);
|
||||||
feedbackCheckbox.OnClick = () => toggleFilterFlag(TextNotificationPoolFilters.Feedback);
|
feedbackCheckbox.OnClick = () => ToggleFilterFlag(TextNotificationPoolFilters.Feedback);
|
||||||
}
|
}
|
||||||
|
|
||||||
var transientsCheckbox = panel.GetOrNull<CheckboxWidget>("TRANSIENTS_CHECKBOX");
|
var transientsCheckbox = panel.GetOrNull<CheckboxWidget>("TRANSIENTS_CHECKBOX");
|
||||||
if (transientsCheckbox != null)
|
if (transientsCheckbox != null)
|
||||||
{
|
{
|
||||||
transientsCheckbox.IsChecked = () => gs.TextNotificationPoolFilters.HasFlag(TextNotificationPoolFilters.Transients);
|
transientsCheckbox.IsChecked = () => gs.TextNotificationPoolFilters.HasFlag(TextNotificationPoolFilters.Transients);
|
||||||
transientsCheckbox.OnClick = () => toggleFilterFlag(TextNotificationPoolFilters.Transients);
|
transientsCheckbox.OnClick = () => ToggleFilterFlag(TextNotificationPoolFilters.Transients);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -391,7 +391,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
{ modData.Translation.GetString(AlwaysShow), StatusBarsType.AlwaysShow },
|
{ modData.Translation.GetString(AlwaysShow), StatusBarsType.AlwaysShow },
|
||||||
};
|
};
|
||||||
|
|
||||||
Func<string, ScrollItemWidget, ScrollItemWidget> setupItem = (o, itemTemplate) =>
|
ScrollItemWidget SetupItem(string o, ScrollItemWidget itemTemplate)
|
||||||
{
|
{
|
||||||
var item = ScrollItemWidget.Setup(itemTemplate,
|
var item = ScrollItemWidget.Setup(itemTemplate,
|
||||||
() => s.StatusBars == options[o],
|
() => s.StatusBars == options[o],
|
||||||
@@ -399,14 +399,14 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
|
|
||||||
item.Get<LabelWidget>("LABEL").GetText = () => o;
|
item.Get<LabelWidget>("LABEL").GetText = () => o;
|
||||||
return item;
|
return item;
|
||||||
};
|
}
|
||||||
|
|
||||||
dropdown.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 500, options.Keys, setupItem);
|
dropdown.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 500, options.Keys, SetupItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ShowDisplaySelectionDropdown(DropDownButtonWidget dropdown, GraphicSettings s)
|
static void ShowDisplaySelectionDropdown(DropDownButtonWidget dropdown, GraphicSettings s)
|
||||||
{
|
{
|
||||||
Func<int, ScrollItemWidget, ScrollItemWidget> setupItem = (o, itemTemplate) =>
|
ScrollItemWidget SetupItem(int o, ScrollItemWidget itemTemplate)
|
||||||
{
|
{
|
||||||
var item = ScrollItemWidget.Setup(itemTemplate,
|
var item = ScrollItemWidget.Setup(itemTemplate,
|
||||||
() => s.VideoDisplay == o,
|
() => s.VideoDisplay == o,
|
||||||
@@ -415,14 +415,14 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
var label = $"Display {o + 1}";
|
var label = $"Display {o + 1}";
|
||||||
item.Get<LabelWidget>("LABEL").GetText = () => label;
|
item.Get<LabelWidget>("LABEL").GetText = () => label;
|
||||||
return item;
|
return item;
|
||||||
};
|
}
|
||||||
|
|
||||||
dropdown.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 500, Enumerable.Range(0, Game.Renderer.DisplayCount), setupItem);
|
dropdown.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 500, Enumerable.Range(0, Game.Renderer.DisplayCount), SetupItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ShowGLProfileDropdown(DropDownButtonWidget dropdown, GraphicSettings s)
|
static void ShowGLProfileDropdown(DropDownButtonWidget dropdown, GraphicSettings s)
|
||||||
{
|
{
|
||||||
Func<GLProfile, ScrollItemWidget, ScrollItemWidget> setupItem = (o, itemTemplate) =>
|
ScrollItemWidget SetupItem(GLProfile o, ScrollItemWidget itemTemplate)
|
||||||
{
|
{
|
||||||
var item = ScrollItemWidget.Setup(itemTemplate,
|
var item = ScrollItemWidget.Setup(itemTemplate,
|
||||||
() => s.GLProfile == o,
|
() => s.GLProfile == o,
|
||||||
@@ -431,10 +431,10 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
var label = o.ToString();
|
var label = o.ToString();
|
||||||
item.Get<LabelWidget>("LABEL").GetText = () => label;
|
item.Get<LabelWidget>("LABEL").GetText = () => label;
|
||||||
return item;
|
return item;
|
||||||
};
|
}
|
||||||
|
|
||||||
var profiles = new[] { GLProfile.Automatic }.Concat(Game.Renderer.SupportedGLProfiles);
|
var profiles = new[] { GLProfile.Automatic }.Concat(Game.Renderer.SupportedGLProfiles);
|
||||||
dropdown.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 500, profiles, setupItem);
|
dropdown.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 500, profiles, SetupItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ShowTargetLinesDropdown(ModData modData, DropDownButtonWidget dropdown, GameSettings s)
|
static void ShowTargetLinesDropdown(ModData modData, DropDownButtonWidget dropdown, GameSettings s)
|
||||||
@@ -446,7 +446,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
{ modData.Translation.GetString(Disabled), TargetLinesType.Disabled },
|
{ modData.Translation.GetString(Disabled), TargetLinesType.Disabled },
|
||||||
};
|
};
|
||||||
|
|
||||||
Func<string, ScrollItemWidget, ScrollItemWidget> setupItem = (o, itemTemplate) =>
|
ScrollItemWidget SetupItem(string o, ScrollItemWidget itemTemplate)
|
||||||
{
|
{
|
||||||
var item = ScrollItemWidget.Setup(itemTemplate,
|
var item = ScrollItemWidget.Setup(itemTemplate,
|
||||||
() => s.TargetLines == options[o],
|
() => s.TargetLines == options[o],
|
||||||
@@ -454,14 +454,14 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
|
|
||||||
item.Get<LabelWidget>("LABEL").GetText = () => o;
|
item.Get<LabelWidget>("LABEL").GetText = () => o;
|
||||||
return item;
|
return item;
|
||||||
};
|
}
|
||||||
|
|
||||||
dropdown.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 500, options.Keys, setupItem);
|
dropdown.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 500, options.Keys, SetupItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void ShowBattlefieldCameraDropdown(ModData modData, DropDownButtonWidget dropdown, WorldViewportSizes viewportSizes, GraphicSettings gs)
|
public static void ShowBattlefieldCameraDropdown(ModData modData, DropDownButtonWidget dropdown, WorldViewportSizes viewportSizes, GraphicSettings gs)
|
||||||
{
|
{
|
||||||
Func<WorldViewport, ScrollItemWidget, ScrollItemWidget> setupItem = (o, itemTemplate) =>
|
ScrollItemWidget SetupItem(WorldViewport o, ScrollItemWidget itemTemplate)
|
||||||
{
|
{
|
||||||
var item = ScrollItemWidget.Setup(itemTemplate,
|
var item = ScrollItemWidget.Setup(itemTemplate,
|
||||||
() => gs.ViewportDistance == o,
|
() => gs.ViewportDistance == o,
|
||||||
@@ -470,7 +470,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
var label = GetViewportSizeName(modData, o);
|
var label = GetViewportSizeName(modData, o);
|
||||||
item.Get<LabelWidget>("LABEL").GetText = () => label;
|
item.Get<LabelWidget>("LABEL").GetText = () => label;
|
||||||
return item;
|
return item;
|
||||||
};
|
}
|
||||||
|
|
||||||
var windowHeight = Game.Renderer.NativeResolution.Height;
|
var windowHeight = Game.Renderer.NativeResolution.Height;
|
||||||
|
|
||||||
@@ -485,7 +485,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
if (viewportSizes.AllowNativeZoom && farRange.Y < windowHeight)
|
if (viewportSizes.AllowNativeZoom && farRange.Y < windowHeight)
|
||||||
validSizes.Add(WorldViewport.Native);
|
validSizes.Add(WorldViewport.Native);
|
||||||
|
|
||||||
dropdown.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 500, validSizes, setupItem);
|
dropdown.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 500, validSizes, SetupItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void RecalculateWidgetLayout(Widget w, bool insideScrollPanel = false)
|
static void RecalculateWidgetLayout(Widget w, bool insideScrollPanel = false)
|
||||||
@@ -533,7 +533,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
|
|
||||||
public static void ShowUIScaleDropdown(DropDownButtonWidget dropdown, GraphicSettings gs)
|
public static void ShowUIScaleDropdown(DropDownButtonWidget dropdown, GraphicSettings gs)
|
||||||
{
|
{
|
||||||
Func<float, ScrollItemWidget, ScrollItemWidget> setupItem = (o, itemTemplate) =>
|
ScrollItemWidget SetupItem(float o, ScrollItemWidget itemTemplate)
|
||||||
{
|
{
|
||||||
var item = ScrollItemWidget.Setup(itemTemplate,
|
var item = ScrollItemWidget.Setup(itemTemplate,
|
||||||
() => gs.UIScale == o,
|
() => gs.UIScale == o,
|
||||||
@@ -553,14 +553,14 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
var label = $"{(int)(100 * o)}%";
|
var label = $"{(int)(100 * o)}%";
|
||||||
item.Get<LabelWidget>("LABEL").GetText = () => label;
|
item.Get<LabelWidget>("LABEL").GetText = () => label;
|
||||||
return item;
|
return item;
|
||||||
};
|
}
|
||||||
|
|
||||||
var viewportSizes = Game.ModData.Manifest.Get<WorldViewportSizes>();
|
var viewportSizes = Game.ModData.Manifest.Get<WorldViewportSizes>();
|
||||||
var maxScales = new float2(Game.Renderer.NativeResolution) / new float2(viewportSizes.MinEffectiveResolution);
|
var maxScales = new float2(Game.Renderer.NativeResolution) / new float2(viewportSizes.MinEffectiveResolution);
|
||||||
var maxScale = Math.Min(maxScales.X, maxScales.Y);
|
var maxScale = Math.Min(maxScales.X, maxScales.Y);
|
||||||
|
|
||||||
var validScales = new[] { 1f, 1.25f, 1.5f, 1.75f, 2f }.Where(x => x <= maxScale);
|
var validScales = new[] { 1f, 1.25f, 1.5f, 1.75f, 2f }.Where(x => x <= maxScale);
|
||||||
dropdown.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 500, validScales, setupItem);
|
dropdown.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 500, validScales, SetupItem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -170,16 +170,16 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
{ modData.Translation.GetString(Modern), false },
|
{ modData.Translation.GetString(Modern), false },
|
||||||
};
|
};
|
||||||
|
|
||||||
Func<string, ScrollItemWidget, ScrollItemWidget> setupItem = (o, itemTemplate) =>
|
ScrollItemWidget SetupItem(string o, ScrollItemWidget itemTemplate)
|
||||||
{
|
{
|
||||||
var item = ScrollItemWidget.Setup(itemTemplate,
|
var item = ScrollItemWidget.Setup(itemTemplate,
|
||||||
() => s.UseClassicMouseStyle == options[o],
|
() => s.UseClassicMouseStyle == options[o],
|
||||||
() => s.UseClassicMouseStyle = options[o]);
|
() => s.UseClassicMouseStyle = options[o]);
|
||||||
item.Get<LabelWidget>("LABEL").GetText = () => o;
|
item.Get<LabelWidget>("LABEL").GetText = () => o;
|
||||||
return item;
|
return item;
|
||||||
};
|
}
|
||||||
|
|
||||||
dropdown.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 500, options.Keys, setupItem);
|
dropdown.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 500, options.Keys, SetupItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ShowMouseScrollDropdown(ModData modData, DropDownButtonWidget dropdown, GameSettings s)
|
static void ShowMouseScrollDropdown(ModData modData, DropDownButtonWidget dropdown, GameSettings s)
|
||||||
@@ -192,16 +192,16 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
{ modData.Translation.GetString(Joystick), MouseScrollType.Joystick },
|
{ modData.Translation.GetString(Joystick), MouseScrollType.Joystick },
|
||||||
};
|
};
|
||||||
|
|
||||||
Func<string, ScrollItemWidget, ScrollItemWidget> setupItem = (o, itemTemplate) =>
|
ScrollItemWidget SetupItem(string o, ScrollItemWidget itemTemplate)
|
||||||
{
|
{
|
||||||
var item = ScrollItemWidget.Setup(itemTemplate,
|
var item = ScrollItemWidget.Setup(itemTemplate,
|
||||||
() => s.MouseScroll == options[o],
|
() => s.MouseScroll == options[o],
|
||||||
() => s.MouseScroll = options[o]);
|
() => s.MouseScroll = options[o]);
|
||||||
item.Get<LabelWidget>("LABEL").GetText = () => o;
|
item.Get<LabelWidget>("LABEL").GetText = () => o;
|
||||||
return item;
|
return item;
|
||||||
};
|
}
|
||||||
|
|
||||||
dropdown.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 500, options.Keys, setupItem);
|
dropdown.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 500, options.Keys, SetupItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ShowZoomModifierDropdown(ModData modData, DropDownButtonWidget dropdown, GameSettings s)
|
static void ShowZoomModifierDropdown(ModData modData, DropDownButtonWidget dropdown, GameSettings s)
|
||||||
@@ -215,16 +215,16 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
{ modData.Translation.GetString(None), Modifiers.None }
|
{ modData.Translation.GetString(None), Modifiers.None }
|
||||||
};
|
};
|
||||||
|
|
||||||
Func<string, ScrollItemWidget, ScrollItemWidget> setupItem = (o, itemTemplate) =>
|
ScrollItemWidget SetupItem(string o, ScrollItemWidget itemTemplate)
|
||||||
{
|
{
|
||||||
var item = ScrollItemWidget.Setup(itemTemplate,
|
var item = ScrollItemWidget.Setup(itemTemplate,
|
||||||
() => s.ZoomModifier == options[o],
|
() => s.ZoomModifier == options[o],
|
||||||
() => s.ZoomModifier = options[o]);
|
() => s.ZoomModifier = options[o]);
|
||||||
item.Get<LabelWidget>("LABEL").GetText = () => o;
|
item.Get<LabelWidget>("LABEL").GetText = () => o;
|
||||||
return item;
|
return item;
|
||||||
};
|
}
|
||||||
|
|
||||||
dropdown.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 500, options.Keys, setupItem);
|
dropdown.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 500, options.Keys, SetupItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void MakeMouseFocusSettingsLive()
|
static void MakeMouseFocusSettingsLive()
|
||||||
|
|||||||
@@ -105,46 +105,46 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
var current = Game.Settings;
|
var current = Game.Settings;
|
||||||
current.Save();
|
current.Save();
|
||||||
|
|
||||||
Action closeAndExit = () => { Ui.CloseWindow(); onExit(); };
|
void CloseAndExit() { Ui.CloseWindow(); onExit(); }
|
||||||
if (needsRestart)
|
if (needsRestart)
|
||||||
{
|
{
|
||||||
Action noRestart = () => ConfirmationDialogs.ButtonPrompt(modData,
|
void NoRestart() => ConfirmationDialogs.ButtonPrompt(modData,
|
||||||
title: SettingsSaveTitle,
|
title: SettingsSaveTitle,
|
||||||
text: SettingsSavePrompt,
|
text: SettingsSavePrompt,
|
||||||
onCancel: closeAndExit,
|
onCancel: CloseAndExit,
|
||||||
cancelText: SettingsSaveCancel);
|
cancelText: SettingsSaveCancel);
|
||||||
|
|
||||||
if (!Game.ExternalMods.TryGetValue(ExternalMod.MakeKey(Game.ModData.Manifest), out var external))
|
if (!Game.ExternalMods.TryGetValue(ExternalMod.MakeKey(Game.ModData.Manifest), out var external))
|
||||||
{
|
{
|
||||||
noRestart();
|
NoRestart();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ConfirmationDialogs.ButtonPrompt(modData,
|
ConfirmationDialogs.ButtonPrompt(modData,
|
||||||
title: RestartTitle,
|
title: RestartTitle,
|
||||||
text: RestartPrompt,
|
text: RestartPrompt,
|
||||||
onConfirm: () => Game.SwitchToExternalMod(external, null, noRestart),
|
onConfirm: () => Game.SwitchToExternalMod(external, null, NoRestart),
|
||||||
onCancel: closeAndExit,
|
onCancel: CloseAndExit,
|
||||||
confirmText: RestartAccept,
|
confirmText: RestartAccept,
|
||||||
cancelText: RestartCancel);
|
cancelText: RestartCancel);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
closeAndExit();
|
CloseAndExit();
|
||||||
};
|
};
|
||||||
|
|
||||||
widget.Get<ButtonWidget>("RESET_BUTTON").OnClick = () =>
|
widget.Get<ButtonWidget>("RESET_BUTTON").OnClick = () =>
|
||||||
{
|
{
|
||||||
Action reset = () =>
|
void Reset()
|
||||||
{
|
{
|
||||||
resetPanelActions[activePanel]();
|
resetPanelActions[activePanel]();
|
||||||
Game.Settings.Save();
|
Game.Settings.Save();
|
||||||
};
|
}
|
||||||
|
|
||||||
ConfirmationDialogs.ButtonPrompt(modData,
|
ConfirmationDialogs.ButtonPrompt(modData,
|
||||||
title: ResetTitle,
|
title: ResetTitle,
|
||||||
titleArguments: Translation.Arguments("panel", panels[activePanel]),
|
titleArguments: Translation.Arguments("panel", panels[activePanel]),
|
||||||
text: ResetPrompt,
|
text: ResetPrompt,
|
||||||
onConfirm: reset,
|
onConfirm: Reset,
|
||||||
onCancel: () => { },
|
onCancel: () => { },
|
||||||
confirmText: ResetAccept,
|
confirmText: ResetAccept,
|
||||||
cancelText: ResetCancel);
|
cancelText: ResetCancel);
|
||||||
|
|||||||
@@ -400,7 +400,7 @@ namespace OpenRA.Mods.Common.Widgets
|
|||||||
{
|
{
|
||||||
var key = Hotkey.FromKeyInput(e);
|
var key = Hotkey.FromKeyInput(e);
|
||||||
|
|
||||||
Func<HotkeyReference, ScrollDirection, bool> handleMapScrollKey = (hotkey, scrollDirection) =>
|
bool HandleMapScrollKey(HotkeyReference hotkey, ScrollDirection scrollDirection)
|
||||||
{
|
{
|
||||||
var isHotkey = false;
|
var isHotkey = false;
|
||||||
var keyValue = hotkey.GetValue();
|
var keyValue = hotkey.GetValue();
|
||||||
@@ -411,10 +411,10 @@ namespace OpenRA.Mods.Common.Widgets
|
|||||||
}
|
}
|
||||||
|
|
||||||
return isHotkey;
|
return isHotkey;
|
||||||
};
|
}
|
||||||
|
|
||||||
if (handleMapScrollKey(ScrollUpKey, ScrollDirection.Up) || handleMapScrollKey(ScrollDownKey, ScrollDirection.Down)
|
if (HandleMapScrollKey(ScrollUpKey, ScrollDirection.Up) || HandleMapScrollKey(ScrollDownKey, ScrollDirection.Down)
|
||||||
|| handleMapScrollKey(ScrollLeftKey, ScrollDirection.Left) || handleMapScrollKey(ScrollRightKey, ScrollDirection.Right))
|
|| HandleMapScrollKey(ScrollLeftKey, ScrollDirection.Left) || HandleMapScrollKey(ScrollRightKey, ScrollDirection.Right))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (e.Event != KeyInputEvent.Down)
|
if (e.Event != KeyInputEvent.Down)
|
||||||
|
|||||||
@@ -9,7 +9,6 @@
|
|||||||
*/
|
*/
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using OpenRA.Mods.Common.Traits;
|
using OpenRA.Mods.Common.Traits;
|
||||||
using OpenRA.Primitives;
|
using OpenRA.Primitives;
|
||||||
@@ -93,16 +92,16 @@ namespace OpenRA.Mods.D2k.Traits
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Func<Actor, bool> isValidTarget = a =>
|
bool IsValidTarget(Actor a)
|
||||||
{
|
{
|
||||||
if (!a.Info.HasTraitInfo<AttractsWormsInfo>())
|
if (!a.Info.HasTraitInfo<AttractsWormsInfo>())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return mobile.CanEnterCell(a.Location, null, BlockedByActor.None);
|
return mobile.CanEnterCell(a.Location, null, BlockedByActor.None);
|
||||||
};
|
}
|
||||||
|
|
||||||
var actorsInRange = self.World.FindActorsInCircle(self.CenterPosition, WormInfo.MaxSearchRadius)
|
var actorsInRange = self.World.FindActorsInCircle(self.CenterPosition, WormInfo.MaxSearchRadius)
|
||||||
.Where(isValidTarget).SelectMany(a => a.TraitsImplementing<AttractsWorms>());
|
.Where(IsValidTarget).SelectMany(a => a.TraitsImplementing<AttractsWorms>());
|
||||||
|
|
||||||
var noiseDirection = actorsInRange.Aggregate(WVec.Zero, (a, b) => a + b.AttractionAtPosition(self.CenterPosition));
|
var noiseDirection = actorsInRange.Aggregate(WVec.Zero, (a, b) => a + b.AttractionAtPosition(self.CenterPosition));
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user