Made SheetBuilder rely on global settings rather than global renderer.
Additionally exposed an InitializeSettings method on game to initialize the global settings so that other classes can set up all the secret dependencies on the global settings required.
This commit is contained in:
@@ -46,6 +46,7 @@ namespace OpenRA.Editor
|
|||||||
miniMapBox.Image = null;
|
miniMapBox.Image = null;
|
||||||
currentMod = toolStripComboBox1.SelectedItem as string;
|
currentMod = toolStripComboBox1.SelectedItem as string;
|
||||||
|
|
||||||
|
Game.InitializeSettings(Arguments.Empty);
|
||||||
Game.modData = new ModData(currentMod);
|
Game.modData = new ModData(currentMod);
|
||||||
GlobalFileSystem.LoadFromManifest(Game.modData.Manifest);
|
GlobalFileSystem.LoadFromManifest(Game.modData.Manifest);
|
||||||
Program.Rules = Game.modData.RulesetCache.LoadDefaultRules();
|
Program.Rules = Game.modData.RulesetCache.LoadDefaultRules();
|
||||||
@@ -203,10 +204,10 @@ namespace OpenRA.Editor
|
|||||||
Height = bitmap.Height / 2,
|
Height = bitmap.Height / 2,
|
||||||
SizeMode = PictureBoxSizeMode.StretchImage
|
SizeMode = PictureBoxSizeMode.StretchImage
|
||||||
};
|
};
|
||||||
|
|
||||||
var brushTemplate = new BrushTemplate { Bitmap = bitmap, N = t.Key };
|
var brushTemplate = new BrushTemplate { Bitmap = bitmap, N = t.Key };
|
||||||
ibox.Click += (_, e) => surface1.SetTool(new BrushTool(brushTemplate));
|
ibox.Click += (_, e) => surface1.SetTool(new BrushTool(brushTemplate));
|
||||||
|
|
||||||
var template = t.Value;
|
var template = t.Value;
|
||||||
tilePalette.Controls.Add(ibox);
|
tilePalette.Controls.Add(ibox);
|
||||||
tt.SetToolTip(ibox, "{1}:{0} ({2}x{3})".F(template.Image, template.Id, template.Size.X, template.Size.Y));
|
tt.SetToolTip(ibox, "{1}:{0} ({2}x{3})".F(template.Image, template.Id, template.Size.X, template.Size.Y));
|
||||||
@@ -463,7 +464,7 @@ namespace OpenRA.Editor
|
|||||||
void ExportMinimap(object sender, EventArgs e)
|
void ExportMinimap(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
using (var sfd = new SaveFileDialog()
|
using (var sfd = new SaveFileDialog()
|
||||||
{
|
{
|
||||||
InitialDirectory = Path.Combine(Environment.CurrentDirectory, "maps"),
|
InitialDirectory = Path.Combine(Environment.CurrentDirectory, "maps"),
|
||||||
DefaultExt = "*.png",
|
DefaultExt = "*.png",
|
||||||
Filter = "PNG Image (*.png)|*.png",
|
Filter = "PNG Image (*.png)|*.png",
|
||||||
@@ -471,9 +472,8 @@ namespace OpenRA.Editor
|
|||||||
FileName = Path.ChangeExtension(loadedMapName, ".png"),
|
FileName = Path.ChangeExtension(loadedMapName, ".png"),
|
||||||
RestoreDirectory = true
|
RestoreDirectory = true
|
||||||
})
|
})
|
||||||
|
if (DialogResult.OK == sfd.ShowDialog())
|
||||||
if (DialogResult.OK == sfd.ShowDialog())
|
miniMapBox.Image.Save(sfd.FileName);
|
||||||
miniMapBox.Image.Save(sfd.FileName);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShowActorNamesClicked(object sender, EventArgs e)
|
void ShowActorNamesClicked(object sender, EventArgs e)
|
||||||
@@ -637,7 +637,7 @@ namespace OpenRA.Editor
|
|||||||
{
|
{
|
||||||
ShowGridClicked(sender, e);
|
ShowGridClicked(sender, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int CalculateTotalResource()
|
public int CalculateTotalResource()
|
||||||
{
|
{
|
||||||
var totalResource = 0;
|
var totalResource = 0;
|
||||||
@@ -651,7 +651,7 @@ namespace OpenRA.Editor
|
|||||||
|
|
||||||
return totalResource;
|
return totalResource;
|
||||||
}
|
}
|
||||||
|
|
||||||
int GetAdjecentCellsWith(int resourceType, int x, int y)
|
int GetAdjecentCellsWith(int resourceType, int x, int y)
|
||||||
{
|
{
|
||||||
var sum = 0;
|
var sum = 0;
|
||||||
|
|||||||
@@ -175,13 +175,18 @@ namespace OpenRA
|
|||||||
public static Modifiers GetModifierKeys() { return modifiers; }
|
public static Modifiers GetModifierKeys() { return modifiers; }
|
||||||
internal static void HandleModifierKeys(Modifiers mods) { modifiers = mods; }
|
internal static void HandleModifierKeys(Modifiers mods) { modifiers = mods; }
|
||||||
|
|
||||||
|
public static void InitializeSettings(Arguments args)
|
||||||
|
{
|
||||||
|
Settings = new Settings(Platform.ResolvePath("^", "settings.yaml"), args);
|
||||||
|
}
|
||||||
|
|
||||||
internal static void Initialize(Arguments args)
|
internal static void Initialize(Arguments args)
|
||||||
{
|
{
|
||||||
Console.WriteLine("Platform is {0}", Platform.CurrentPlatform);
|
Console.WriteLine("Platform is {0}", Platform.CurrentPlatform);
|
||||||
|
|
||||||
AppDomain.CurrentDomain.AssemblyResolve += GlobalFileSystem.ResolveAssembly;
|
AppDomain.CurrentDomain.AssemblyResolve += GlobalFileSystem.ResolveAssembly;
|
||||||
|
|
||||||
Settings = new Settings(Platform.ResolvePath("^", "settings.yaml"), args);
|
InitializeSettings(args);
|
||||||
|
|
||||||
Log.AddChannel("perf", "perf.log");
|
Log.AddChannel("perf", "perf.log");
|
||||||
Log.AddChannel("debug", "debug.log");
|
Log.AddChannel("debug", "debug.log");
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ namespace OpenRA.Graphics
|
|||||||
}
|
}
|
||||||
|
|
||||||
public SheetBuilder(SheetType t)
|
public SheetBuilder(SheetType t)
|
||||||
: this(t, Game.Renderer.SheetSize) { }
|
: this(t, Game.Settings.Graphics.SheetSize) { }
|
||||||
|
|
||||||
public SheetBuilder(SheetType t, int sheetSize)
|
public SheetBuilder(SheetType t, int sheetSize)
|
||||||
: this(t, () => AllocateSheet(sheetSize)) { }
|
: this(t, () => AllocateSheet(sheetSize)) { }
|
||||||
|
|||||||
@@ -55,9 +55,7 @@ namespace OpenRA.Lint
|
|||||||
FieldLoader.UnknownFieldAction = (s, f) => EmitError("FieldLoader: Missing field `{0}` on `{1}`".F(s, f.Name));
|
FieldLoader.UnknownFieldAction = (s, f) => EmitError("FieldLoader: Missing field `{0}` on `{1}`".F(s, f.Name));
|
||||||
|
|
||||||
AppDomain.CurrentDomain.AssemblyResolve += GlobalFileSystem.ResolveAssembly;
|
AppDomain.CurrentDomain.AssemblyResolve += GlobalFileSystem.ResolveAssembly;
|
||||||
Game.Renderer = new Graphics.Renderer(
|
Game.InitializeSettings(Arguments.Empty);
|
||||||
new GraphicSettings() { Renderer = "Null", NumTempBuffers = 0, SheetSize = 0 },
|
|
||||||
new ServerSettings());
|
|
||||||
Game.modData = new ModData(mod);
|
Game.modData = new ModData(mod);
|
||||||
|
|
||||||
IEnumerable<Map> maps;
|
IEnumerable<Map> maps;
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ namespace OpenRA.Utility
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Game.InitializeSettings(Arguments.Empty);
|
||||||
var modData = new ModData(modName);
|
var modData = new ModData(modName);
|
||||||
args = args.Skip(1).ToArray();
|
args = args.Skip(1).ToArray();
|
||||||
var actions = new Dictionary<string, Action<ModData, string[]>>();
|
var actions = new Dictionary<string, Action<ModData, string[]>>();
|
||||||
|
|||||||
Reference in New Issue
Block a user