add ChromeMetrics for values we dont want to duplicate everywhere

This commit is contained in:
Chris Forbes
2011-05-16 21:06:04 +12:00
committed by Paul Chote
parent c270f9ff4a
commit b183366d54
10 changed files with 71 additions and 10 deletions

View File

@@ -20,7 +20,7 @@ namespace OpenRA.FileFormats
public readonly string[]
Mods, Folders, Packages, Rules, ServerTraits,
Sequences, Cursors, Chrome, Assemblies, ChromeLayout,
Weapons, Voices, Music, Movies, TileSets;
Weapons, Voices, Music, Movies, TileSets, ChromeMetrics;
public readonly string LoadScreen;
public readonly int TileSize = 24;
@@ -46,6 +46,7 @@ namespace OpenRA.FileFormats
Music = YamlList(yaml, "Music");
Movies = YamlList(yaml, "Movies");
TileSets = YamlList(yaml, "TileSets");
ChromeMetrics = YamlList(yaml, "ChromeMetrics");
LoadScreen = yaml.First( x => x.Key == "LoadScreen" ).Value.Value;

View File

@@ -14,6 +14,7 @@ using System.Linq;
using OpenRA.FileFormats;
using OpenRA.Graphics;
using OpenRA.Traits;
using OpenRA.Widgets;
namespace OpenRA
{
@@ -44,22 +45,23 @@ namespace OpenRA
{
AvailableMaps = FindMaps( Manifest.Mods );
}
public void LoadInitialAssets()
{
// all this manipulation of static crap here is nasty and breaks
// horribly when you use ModData in unexpected ways.
// horribly when you use ModData in unexpected ways.
FileSystem.UnmountAll();
foreach (var dir in Manifest.Folders)
FileSystem.Mount(dir);
ReloadMaps();
Palette = new HardwarePalette();
ChromeProvider.Initialize( Manifest.Chrome );
SheetBuilder = new SheetBuilder( TextureChannel.Red );
CursorSheetBuilder = new CursorSheetBuilder( this );
ChromeMetrics.Initialize(Manifest.ChromeMetrics);
ChromeProvider.Initialize(Manifest.Chrome);
SheetBuilder = new SheetBuilder(TextureChannel.Red);
CursorSheetBuilder = new CursorSheetBuilder(this);
CursorProvider.Initialize(Manifest.Cursors);
Palette.Update(new IPaletteModifier[]{});
Palette.Update(new IPaletteModifier[] { });
}
public Map PrepareMap(string uid)

View File

@@ -204,6 +204,7 @@
<Compile Include="Traits\Target.cs" />
<Compile Include="Traits\ValidateOrder.cs" />
<Compile Include="TraitDictionary.cs" />
<Compile Include="Widgets\ChromeMetrics.cs" />
<Compile Include="Widgets\PasswordFieldWidget.cs" />
<Compile Include="Widgets\ScrollingTextWidget.cs" />
</ItemGroup>

View File

@@ -9,9 +9,9 @@
#endregion
using System;
using System.Collections.Generic;
using System.Drawing;
using OpenRA.Graphics;
using System.Collections.Generic;
namespace OpenRA.Widgets
{

View File

@@ -0,0 +1,43 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see COPYING.
*/
#endregion
using System.Collections.Generic;
using System.Linq;
using OpenRA.FileFormats;
namespace OpenRA.Widgets
{
static class ChromeMetrics
{
static Dictionary<string, string> data = new Dictionary<string, string>();
public static void Initialize(string[] yaml)
{
data = new Dictionary<string, string>();
var metrics = yaml.Select(y => MiniYaml.FromFile(y))
.Aggregate(MiniYaml.MergeLiberal);
foreach (var m in metrics)
foreach (var n in m.Value.Nodes)
data[n.Key] = n.Value.Value;
}
public static string GetString(string key)
{
return data[key];
}
public static int GetInt(string key)
{
return int.Parse(data[key]);
}
}
}

View File

@@ -9,10 +9,10 @@
#endregion
using System.Collections.Generic;
using System.IO;
using System.Linq;
using OpenRA.FileFormats;
using OpenRA.Widgets;
using System.IO;
namespace OpenRA
{

4
mods/cnc/metrics.yaml Normal file
View File

@@ -0,0 +1,4 @@
# General dumping-ground for UI element sizes, etc.
Metrics:
ButtonDepth: 1

View File

@@ -92,3 +92,6 @@ ServerTraits:
PlayerCommands
LobbyCommands
MasterServerPinger
ChromeMetrics:
mods/cnc/metrics.yaml

4
mods/ra/metrics.yaml Normal file
View File

@@ -0,0 +1,4 @@
# General dumping-ground for UI element sizes, etc.
Metrics:
ButtonDepth: 1

View File

@@ -86,3 +86,6 @@ ServerTraits:
PlayerCommands
LobbyCommands
MasterServerPinger
ChromeMetrics:
mods/ra/metrics.yaml