Improve replay metadata and the replay browser
List of changes: * Better and more filters with new layout, for both mods. * Rename/Delete/Detele all functionality. * Simplified ReplayMetadata class considerably by introducing a new GameInformation data object. The new GameInformation class contains more information than previously available so the new solution is not compatible with old replays, meaning it can't read old replays. * Better and cleaner game information gathering in order to be written at the end of the replay file. * Revert changes to ReplayConnection, no longer necessary. * Better exception message on missing sprites and fonts. * New "SpawnOccupant" class that holds all the information needed by the MapPreviewWidget to visualize a spawn point. It was using Session.Client before and it was necessary to separate it to be able to show information not available at lobby time. * Fix keyboard focus UI bug when closing a window would not remove focus.
This commit is contained in:
@@ -41,9 +41,12 @@ namespace OpenRA.Widgets
|
||||
{
|
||||
var name = GetImageName();
|
||||
var collection = GetImageCollection();
|
||||
WidgetUtils.DrawRGBA(
|
||||
ChromeProvider.GetImage(collection, name),
|
||||
RenderOrigin);
|
||||
|
||||
var sprite = ChromeProvider.GetImage(collection, name);
|
||||
if (sprite == null)
|
||||
throw new ArgumentException("Sprite {0}/{1} was not found.".F(collection, name));
|
||||
|
||||
WidgetUtils.DrawRGBA(sprite, RenderOrigin);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,7 +56,10 @@ namespace OpenRA.Widgets
|
||||
|
||||
public override void Draw()
|
||||
{
|
||||
SpriteFont font = Game.Renderer.Fonts[Font];
|
||||
SpriteFont font;
|
||||
if (!Game.Renderer.Fonts.TryGetValue(Font, out font))
|
||||
throw new ArgumentException("Request font '{0}' was not found.".F(Font));
|
||||
|
||||
var text = GetText();
|
||||
if (text == null)
|
||||
return;
|
||||
|
||||
@@ -19,10 +19,42 @@ using OpenRA.Network;
|
||||
|
||||
namespace OpenRA.Widgets
|
||||
{
|
||||
public class SpawnOccupant
|
||||
{
|
||||
public readonly HSLColor Color;
|
||||
public readonly int ClientIndex;
|
||||
public readonly string PlayerName;
|
||||
public readonly int Team;
|
||||
public readonly string Country;
|
||||
public readonly int SpawnPoint;
|
||||
|
||||
public SpawnOccupant()
|
||||
{
|
||||
}
|
||||
public SpawnOccupant(Session.Client client)
|
||||
{
|
||||
Color = client.Color;
|
||||
ClientIndex = client.Index;
|
||||
PlayerName = client.Name;
|
||||
Team = client.Team;
|
||||
Country = client.Country;
|
||||
SpawnPoint = client.SpawnPoint;
|
||||
}
|
||||
public SpawnOccupant(GameInformation.Player player)
|
||||
{
|
||||
Color = player.Color;
|
||||
ClientIndex = player.ClientIndex;
|
||||
PlayerName = player.Name;
|
||||
Team = player.Team;
|
||||
Country = player.FactionId;
|
||||
SpawnPoint = player.SpawnPoint;
|
||||
}
|
||||
}
|
||||
|
||||
public class MapPreviewWidget : Widget
|
||||
{
|
||||
public Func<MapPreview> Preview = () => null;
|
||||
public Func<Dictionary<CPos, Session.Client>> SpawnClients = () => new Dictionary<CPos, Session.Client>();
|
||||
public Func<Dictionary<CPos, SpawnOccupant>> SpawnOccupants = () => new Dictionary<CPos, SpawnOccupant>();
|
||||
public Action<MouseInput> OnMouseDown = _ => {};
|
||||
public bool IgnoreMouseInput = false;
|
||||
public bool ShowSpawnPoints = true;
|
||||
@@ -44,7 +76,7 @@ namespace OpenRA.Widgets
|
||||
: base(other)
|
||||
{
|
||||
Preview = other.Preview;
|
||||
SpawnClients = other.SpawnClients;
|
||||
SpawnOccupants = other.SpawnOccupants;
|
||||
ShowSpawnPoints = other.ShowSpawnPoints;
|
||||
TooltipTemplate = other.TooltipTemplate;
|
||||
TooltipContainer = other.TooltipContainer;
|
||||
@@ -109,7 +141,7 @@ namespace OpenRA.Widgets
|
||||
TooltipSpawnIndex = -1;
|
||||
if (ShowSpawnPoints)
|
||||
{
|
||||
var colors = SpawnClients().ToDictionary(c => c.Key, c => c.Value.Color.RGB);
|
||||
var colors = SpawnOccupants().ToDictionary(c => c.Key, c => c.Value.Color.RGB);
|
||||
|
||||
var spawnPoints = preview.SpawnPoints;
|
||||
foreach (var p in spawnPoints)
|
||||
|
||||
@@ -258,7 +258,7 @@ namespace OpenRA.Widgets
|
||||
return true;
|
||||
}
|
||||
|
||||
// Remove focus from this widget; return false if you don't want to give it up
|
||||
// Remove focus from this widget; return false to hint that you don't want to give it up
|
||||
public virtual bool YieldMouseFocus(MouseInput mi)
|
||||
{
|
||||
if (Ui.MouseFocusWidget == this)
|
||||
@@ -267,6 +267,12 @@ namespace OpenRA.Widgets
|
||||
return true;
|
||||
}
|
||||
|
||||
void ForceYieldMouseFocus()
|
||||
{
|
||||
if (Ui.MouseFocusWidget == this && !YieldMouseFocus(default(MouseInput)))
|
||||
Ui.MouseFocusWidget = null;
|
||||
}
|
||||
|
||||
public virtual bool TakeKeyboardFocus()
|
||||
{
|
||||
if (HasKeyboardFocus)
|
||||
@@ -287,6 +293,12 @@ namespace OpenRA.Widgets
|
||||
return true;
|
||||
}
|
||||
|
||||
void ForceYieldKeyboardFocus()
|
||||
{
|
||||
if (Ui.KeyboardFocusWidget == this && !YieldKeyboardFocus())
|
||||
Ui.KeyboardFocusWidget = null;
|
||||
}
|
||||
|
||||
public virtual string GetCursor(int2 pos) { return "default"; }
|
||||
public string GetCursorOuter(int2 pos)
|
||||
{
|
||||
@@ -410,6 +422,11 @@ namespace OpenRA.Widgets
|
||||
|
||||
public virtual void Removed()
|
||||
{
|
||||
// Using the forced versions because the widgets
|
||||
// have been removed
|
||||
ForceYieldKeyboardFocus();
|
||||
ForceYieldMouseFocus();
|
||||
|
||||
foreach (var c in Children.OfType<Widget>().Reverse())
|
||||
c.Removed();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user