Refactoring to remove static Rules & SequenceProvider

This commit is contained in:
Pavlos Touboulidis
2014-05-05 02:43:08 +03:00
parent c68427eaa6
commit 63ec6d60e7
114 changed files with 914 additions and 615 deletions

32
OpenRA.Mods.RA/Widgets/BuildPaletteWidget.cs Executable file → Normal file
View File

@@ -1,6 +1,6 @@
#region Copyright & License Information
/*
* Copyright 2007-2012 The OpenRA Developers (see AUTHORS)
* Copyright 2007-2014 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,
@@ -124,11 +124,11 @@ namespace OpenRA.Mods.RA.Widgets
// Play palette-open sound at the start of the activate anim (open)
if (paletteAnimationFrame == 1 && paletteOpen)
Sound.PlayNotification(null, "Sounds", "BuildPaletteOpen", null);
Sound.PlayNotification(world.Map.Rules, null, "Sounds", "BuildPaletteOpen", null);
// Play palette-close sound at the start of the activate anim (close)
if (paletteAnimationFrame == paletteAnimationLength + -1 && !paletteOpen)
Sound.PlayNotification(null, "Sounds", "BuildPaletteClose", null);
Sound.PlayNotification(world.Map.Rules, null, "Sounds", "BuildPaletteClose", null);
// Animation is complete
if ((paletteAnimationFrame == 0 && !paletteOpen)
@@ -314,7 +314,7 @@ namespace OpenRA.Mods.RA.Widgets
{
return mi =>
{
Sound.PlayNotification(null, "Sounds", "TabClick", null);
Sound.PlayNotification(world.Map.Rules, null, "Sounds", "TabClick", null);
if (name != null)
HandleBuildPalette(world, name, (mi.Button == MouseButton.Left));
@@ -328,7 +328,7 @@ namespace OpenRA.Mods.RA.Widgets
if (mi.Button != MouseButton.Left)
return;
Sound.PlayNotification(null, "Sounds", "TabClick", null);
Sound.PlayNotification(world.Map.Rules, null, "Sounds", "TabClick", null);
var wasOpen = paletteOpen;
paletteOpen = CurrentQueue != queue || !wasOpen;
CurrentQueue = queue;
@@ -337,10 +337,10 @@ namespace OpenRA.Mods.RA.Widgets
};
}
static string Description(string a)
static string Description(MapRuleset rules, string a)
{
ActorInfo ai;
Rules.Info.TryGetValue(a.ToLowerInvariant(), out ai);
rules.Actors.TryGetValue(a.ToLowerInvariant(), out ai);
if (ai != null && ai.Traits.Contains<TooltipInfo>())
return ai.Traits.Get<TooltipInfo>().Name;
@@ -349,7 +349,7 @@ namespace OpenRA.Mods.RA.Widgets
void HandleBuildPalette(World world, string item, bool isLmb)
{
var unit = Rules.Info[item];
var unit = world.Map.Rules.Actors[item];
var producing = CurrentQueue.AllQueued().FirstOrDefault(a => a.Item == item);
if (isLmb)
@@ -379,9 +379,9 @@ namespace OpenRA.Mods.RA.Widgets
var buildLimit = unit.Traits.Get<BuildableInfo>().BuildLimit;
if (!((buildLimit != 0) && (inWorld + queued >= buildLimit)))
Sound.PlayNotification(world.LocalPlayer, "Speech", CurrentQueue.Info.QueuedAudio, world.LocalPlayer.Country.Race);
Sound.PlayNotification(world.Map.Rules, world.LocalPlayer, "Speech", CurrentQueue.Info.QueuedAudio, world.LocalPlayer.Country.Race);
else
Sound.PlayNotification(world.LocalPlayer, "Speech", CurrentQueue.Info.BlockedAudio, world.LocalPlayer.Country.Race);
Sound.PlayNotification(world.Map.Rules, world.LocalPlayer, "Speech", CurrentQueue.Info.BlockedAudio, world.LocalPlayer.Country.Race);
}
StartProduction(world, item);
@@ -393,14 +393,14 @@ namespace OpenRA.Mods.RA.Widgets
// instant cancel of things we havent really started yet, and things that are finished
if (producing.Paused || producing.Done || producing.TotalCost == producing.RemainingCost)
{
Sound.PlayNotification(world.LocalPlayer, "Speech", CurrentQueue.Info.CancelledAudio, world.LocalPlayer.Country.Race);
Sound.PlayNotification(world.Map.Rules, world.LocalPlayer, "Speech", CurrentQueue.Info.CancelledAudio, world.LocalPlayer.Country.Race);
int numberToCancel = Game.GetModifierKeys().HasModifier(Modifiers.Shift) ? 5 : 1;
world.IssueOrder(Order.CancelProduction(CurrentQueue.self, item, numberToCancel));
}
else
{
Sound.PlayNotification(world.LocalPlayer, "Speech", CurrentQueue.Info.OnHoldAudio, world.LocalPlayer.Country.Race);
Sound.PlayNotification(world.Map.Rules, world.LocalPlayer, "Speech", CurrentQueue.Info.OnHoldAudio, world.LocalPlayer.Country.Race);
world.IssueOrder(Order.PauseProduction(CurrentQueue.self, item, true));
}
}
@@ -463,7 +463,7 @@ namespace OpenRA.Mods.RA.Widgets
var pl = world.LocalPlayer;
var p = pos.ToFloat2() - new float2(297, -3);
var info = Rules.Info[unit];
var info = world.Map.Rules.Actors[unit];
var tooltip = info.Traits.Get<TooltipInfo>();
var buildable = info.Traits.Get<BuildableInfo>();
var cost = info.Traits.Get<ValuedInfo>().Cost;
@@ -497,7 +497,7 @@ namespace OpenRA.Mods.RA.Widgets
p += new int2(5, 35);
if (!canBuildThis)
{
var prereqs = buildable.Prerequisites.Select(Description);
var prereqs = buildable.Prerequisites.Select(s => Description(world.Map.Rules, s));
if (prereqs.Any())
{
Game.Renderer.Fonts["Regular"].DrawText(RequiresText.F(prereqs.JoinWith(", ")), p.ToInt2(), Color.White);
@@ -520,7 +520,7 @@ namespace OpenRA.Mods.RA.Widgets
if (toBuild != null)
{
Sound.PlayNotification(null, "Sounds", "TabClick", null);
Sound.PlayNotification(world.Map.Rules, null, "Sounds", "TabClick", null);
HandleBuildPalette(world, toBuild.Name, true);
return true;
}
@@ -531,7 +531,7 @@ namespace OpenRA.Mods.RA.Widgets
// NOTE: Always return true here to prevent mouse events from passing through the sidebar and interacting with the world behind it.
bool ChangeTab(bool reverse)
{
Sound.PlayNotification(null, "Sounds", "TabClick", null);
Sound.PlayNotification(world.Map.Rules, null, "Sounds", "TabClick", null);
var queues = VisibleQueues.Concat(VisibleQueues);
if (reverse)
queues = queues.Reverse();

View File

@@ -1,6 +1,6 @@
#region Copyright & License Information
/*
* Copyright 2007-2013 The OpenRA Developers (see AUTHORS)
* Copyright 2007-2014 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,
@@ -38,11 +38,15 @@ namespace OpenRA.Mods.RA.Widgets.Logic
Sprite[] currentSprites;
int currentFrame;
readonly World world;
static readonly string[] AllowedExtensions = { ".shp", ".r8", "tmp", ".tem", ".des", ".sno", ".int" };
[ObjectCreator.UseCtor]
public AssetBrowserLogic(Widget widget, Action onExit, World world)
{
this.world = world;
panel = widget;
assetSource = GlobalFileSystem.MountedFolders.First();
@@ -192,7 +196,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
return false;
currentFilename = filename;
currentSprites = Game.modData.SpriteLoader.LoadAllSprites(filename);
currentSprites = world.Map.Rules.TileSets[world.Map.Tileset].Data.SpriteLoader.LoadAllSprites(filename);
currentFrame = 0;
frameSlider.MaximumValue = (float)currentSprites.Length - 1;
frameSlider.Ticks = currentSprites.Length;

View File

@@ -20,6 +20,8 @@ namespace OpenRA.Mods.RA.Widgets.Logic
{
public class IngameChatLogic
{
readonly World world;
readonly ContainerWidget chatOverlay;
readonly ChatDisplayWidget chatOverlayDisplay;
@@ -35,6 +37,8 @@ namespace OpenRA.Mods.RA.Widgets.Logic
[ObjectCreator.UseCtor]
public IngameChatLogic(Widget widget, OrderManager orderManager, World world)
{
this.world = world;
chatTraits = world.WorldActor.TraitsImplementing<INotifyChat>().ToList();
var players = world.Players.Where(p => p != world.LocalPlayer && !p.NonCombatant && !p.IsBot);
@@ -161,7 +165,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
if (scrolledToBottom)
chatScrollPanel.ScrollToBottom();
Sound.PlayNotification(null, "Sounds", "ChatLine", null);
Sound.PlayNotification(world.Map.Rules, null, "Sounds", "ChatLine", null);
}
}
}
}

View File

@@ -1,6 +1,6 @@
#region Copyright & License Information
/*
* Copyright 2007-2013 The OpenRA Developers (see AUTHORS)
* Copyright 2007-2014 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,
@@ -18,9 +18,9 @@ namespace OpenRA.Mods.RA.Widgets.Logic
{
public class IngameChromeLogic
{
Widget gameRoot;
Widget playerRoot;
World world;
readonly Widget gameRoot;
readonly Widget playerRoot;
readonly World world;
[ObjectCreator.UseCtor]
public IngameChromeLogic(World world)
@@ -149,7 +149,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
.Any(a => a.Actor.Owner == world.LocalPlayer && a.Trait.IsActive);
if (radarActive != cachedRadarActive)
Sound.PlayNotification(null, "Sounds", (radarActive ? "RadarUp" : "RadarDown"), null);
Sound.PlayNotification(world.Map.Rules, null, "Sounds", (radarActive ? "RadarUp" : "RadarDown"), null);
cachedRadarActive = radarActive;
// Switch to observer mode after win/loss

View File

@@ -63,7 +63,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
widget.Get<ButtonWidget>("MUSIC").OnClick = () =>
{
widget.Visible = false;
Ui.OpenWindow("MUSIC_PANEL", new WidgetArgs { { "onExit", () => { widget.Visible = true; } } });
MusicPlayerLogic.OpenWindow(world, () => { widget.Visible = true; });
};
widget.Get<ButtonWidget>("RESUME").OnClick = () => onExit();
@@ -82,7 +82,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
void LeaveGame(World world)
{
Sound.PlayNotification(null, "Speech", "Leave", world.LocalPlayer == null ? null : world.LocalPlayer.Country.Race);
Sound.PlayNotification(world.Map.Rules, null, "Speech", "Leave", world.LocalPlayer == null ? null : world.LocalPlayer.Country.Race);
Game.Disconnect();
Ui.CloseWindow();
Game.LoadShellMap();

View File

@@ -1,6 +1,6 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* Copyright 2007-2014 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,
@@ -29,6 +29,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
readonly Action onExit;
readonly OrderManager orderManager;
readonly bool skirmishMode;
readonly World world;
enum PanelType { Players, Options, Kick, ForceStart }
PanelType panel = PanelType.Players;
@@ -98,6 +99,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
this.onStart = onStart;
this.onExit = onExit;
this.skirmishMode = skirmishMode;
this.world = world;
Game.LobbyInfoChanged += UpdateCurrentMap;
Game.LobbyInfoChanged += UpdatePlayerList;
@@ -132,7 +134,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
colorPreview = lobby.Get<ColorPreviewManagerWidget>("COLOR_MANAGER");
colorPreview.Color = Game.Settings.Player.Color;
countryNames = Rules.Info["world"].Traits.WithInterface<CountryInfo>()
countryNames = world.Map.Rules.Actors["world"].Traits.WithInterface<CountryInfo>()
.Where(c => c.Selectable)
.ToDictionary(a => a.Race, a => a.Name);
countryNames.Add("random", "Any");
@@ -170,7 +172,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
slotsButton.IsDisabled = () => configurationDisabled() || panel != PanelType.Players ||
!orderManager.LobbyInfo.Slots.Values.Any(s => s.AllowBots || !s.LockTeam);
var botNames = Rules.Info["player"].Traits.WithInterface<IBotInfo>().Select(t => t.Name);
var botNames = world.Map.Rules.Actors["player"].Traits.WithInterface<IBotInfo>().Select(t => t.Name);
slotsButton.OnMouseDown = _ =>
{
var options = new Dictionary<string, IEnumerable<DropDownOption>>();
@@ -375,7 +377,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
};
Func<string, string> className = c => classNames.ContainsKey(c) ? classNames[c] : c;
var classes = Rules.Info["world"].Traits.WithInterface<MPStartUnitsInfo>()
var classes = world.Map.Rules.Actors["world"].Traits.WithInterface<MPStartUnitsInfo>()
.Select(a => a.Class).Distinct();
startingUnits.IsDisabled = () => Map.Status != MapStatus.Available || !Map.Map.Options.ConfigurableStartingUnits || configurationDisabled();
@@ -409,7 +411,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
startingCash.GetText = () => Map.Status != MapStatus.Available || Map.Map.Options.StartingCash.HasValue ? "Not Available" : "${0}".F(orderManager.LobbyInfo.GlobalSettings.StartingCash);
startingCash.OnMouseDown = _ =>
{
var options = Rules.Info["player"].Traits.Get<PlayerResourcesInfo>().SelectableCash.Select(c => new DropDownOption
var options = world.Map.Rules.Actors["player"].Traits.Get<PlayerResourcesInfo>().SelectableCash.Select(c => new DropDownOption
{
Title = "${0}".F(c),
IsSelected = () => orderManager.LobbyInfo.GlobalSettings.StartingCash == c,
@@ -481,7 +483,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
var musicButton = lobby.GetOrNull<ButtonWidget>("MUSIC_BUTTON");
if (musicButton != null)
musicButton.OnClick = () => Ui.OpenWindow("MUSIC_PANEL", new WidgetArgs { { "onExit", DoNothing } });
musicButton.OnClick = () => MusicPlayerLogic.OpenWindow(world);
var settingsButton = lobby.GetOrNull<ButtonWidget>("SETTINGS_BUTTON");
if (settingsButton != null)
@@ -499,7 +501,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
Game.LobbyInfoChanged += WidgetUtils.Once(() =>
{
var slot = orderManager.LobbyInfo.FirstEmptyBotSlot();
var bot = Rules.Info["player"].Traits.WithInterface<IBotInfo>().Select(t => t.Name).FirstOrDefault();
var bot = world.Map.Rules.Actors["player"].Traits.WithInterface<IBotInfo>().Select(t => t.Name).FirstOrDefault();
var botController = orderManager.LobbyInfo.Clients.FirstOrDefault(c => c.IsAdmin);
if (slot != null && bot != null)
orderManager.IssueOrder(Order.Command("slot_bot {0} {1} {2}".F(slot, botController.Index, bot)));
@@ -542,7 +544,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
if (scrolledToBottom)
chatPanel.ScrollToBottom();
Sound.PlayNotification(null, "Sounds", "ChatLine", null);
Sound.PlayNotification(world.Map.Rules, null, "Sounds", "ChatLine", null);
}
void UpdateCurrentMap()
@@ -559,7 +561,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
orderManager.IssueOrder(Order.Command("state {0}".F(Session.ClientState.NotReady)));
// Restore default starting cash if the last map set it to something invalid
var pri = Rules.Info["player"].Traits.Get<PlayerResourcesInfo>();
var pri = world.Map.Rules.Actors["player"].Traits.Get<PlayerResourcesInfo>();
if (!Map.Map.Options.StartingCash.HasValue && !pri.SelectableCash.Contains(orderManager.LobbyInfo.GlobalSettings.StartingCash))
orderManager.IssueOrder(Order.Command("startingcash {0}".F(pri.DefaultCash)));
}
@@ -588,7 +590,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
template = emptySlotTemplate.Clone();
if (Game.IsHost)
LobbyUtils.SetupEditableSlotWidget(template, slot, client, orderManager);
LobbyUtils.SetupEditableSlotWidget(template, slot, client, orderManager, world.Map.Rules);
else
LobbyUtils.SetupSlotWidget(template, slot, client);
@@ -607,7 +609,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
LobbyUtils.SetupClientWidget(template, slot, client, orderManager, client.Bot == null);
if (client.Bot != null)
LobbyUtils.SetupEditableSlotWidget(template, slot, client, orderManager);
LobbyUtils.SetupEditableSlotWidget(template, slot, client, orderManager, world.Map.Rules);
else
LobbyUtils.SetupEditableNameWidget(template, slot, client, orderManager);

View File

@@ -1,6 +1,6 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* Copyright 2007-2014 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,
@@ -37,7 +37,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
}
}
public static void ShowSlotDropDown(DropDownButtonWidget dropdown, Session.Slot slot,
public static void ShowSlotDropDown(MapRuleset rules, DropDownButtonWidget dropdown, Session.Slot slot,
Session.Client client, OrderManager orderManager)
{
var options = new Dictionary<string, IEnumerable<SlotDropDownOption>>() {{"Slot", new List<SlotDropDownOption>()
@@ -49,7 +49,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
var bots = new List<SlotDropDownOption>();
if (slot.AllowBots)
{
foreach (var b in Rules.Info["player"].Traits.WithInterface<IBotInfo>().Select(t => t.Name))
foreach (var b in rules.Actors["player"].Traits.WithInterface<IBotInfo>().Select(t => t.Name))
{
var bot = b;
var botController = orderManager.LobbyInfo.Clients.FirstOrDefault(c => c.IsAdmin);
@@ -280,13 +280,13 @@ namespace OpenRA.Mods.RA.Widgets.Logic
name.GetText = () => c.Name;
}
public static void SetupEditableSlotWidget(Widget parent, Session.Slot s, Session.Client c, OrderManager orderManager)
public static void SetupEditableSlotWidget(Widget parent, Session.Slot s, Session.Client c, OrderManager orderManager, MapRuleset rules)
{
var slot = parent.Get<DropDownButtonWidget>("SLOT_OPTIONS");
slot.IsVisible = () => true;
slot.IsDisabled = () => orderManager.LocalClient.IsReady;
slot.GetText = () => c != null ? c.Name : s.Closed ? "Closed" : "Open";
slot.OnMouseDown = _ => ShowSlotDropDown(slot, s, c, orderManager);
slot.OnMouseDown = _ => ShowSlotDropDown(rules, slot, s, c, orderManager);
// Ensure Name selector (if present) is hidden
var name = parent.GetOrNull("NAME");

View File

@@ -110,10 +110,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
extrasMenu.Get<ButtonWidget>("MUSIC_BUTTON").OnClick = () =>
{
menuType = MenuType.None;
Ui.OpenWindow("MUSIC_PANEL", new WidgetArgs
{
{ "onExit", () => menuType = MenuType.Extras },
});
MusicPlayerLogic.OpenWindow(world, () => menuType = MenuType.Extras);
};
var assetBrowserButton = extrasMenu.GetOrNull<ButtonWidget>("ASSETBROWSER_BUTTON");

View File

@@ -23,8 +23,8 @@ namespace OpenRA.Mods.RA.Widgets.Logic
{
Widget modList;
ButtonWidget modTemplate;
Mod[] allMods;
Mod selectedMod;
ModInformation[] allMods;
ModInformation selectedMod;
string selectedAuthor;
string selectedDescription;
int modOffset = 0;
@@ -67,7 +67,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
var sheetBuilder = new SheetBuilder(SheetType.BGRA);
previews = new Dictionary<string, Sprite>();
logos = new Dictionary<string, Sprite>();
allMods = Mod.AllMods.Values.Where(m => m.Id != "modchooser")
allMods = ModInformation.AllMods.Values.Where(m => m.Id != "modchooser")
.OrderBy(m => m.Title)
.ToArray();
@@ -96,9 +96,9 @@ namespace OpenRA.Mods.RA.Widgets.Logic
}
Mod initialMod = null;
Mod.AllMods.TryGetValue(Game.Settings.Game.PreviousMod, out initialMod);
SelectMod(initialMod ?? Mod.AllMods["ra"]);
ModInformation initialMod = null;
ModInformation.AllMods.TryGetValue(Game.Settings.Game.PreviousMod, out initialMod);
SelectMod(initialMod ?? ModInformation.AllMods["ra"]);
RebuildModList();
}
@@ -147,7 +147,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
}
}
void SelectMod(Mod mod)
void SelectMod(ModInformation mod)
{
selectedMod = mod;
selectedAuthor = "By " + mod.Author ?? "unknown author";
@@ -157,7 +157,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
modOffset = selectedIndex - 4;
}
void LoadMod(Mod mod)
void LoadMod(ModInformation mod)
{
Game.RunAfterTick(() =>
{

View File

@@ -1,6 +1,6 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* Copyright 2007-2014 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,
@@ -18,6 +18,8 @@ namespace OpenRA.Mods.RA.Widgets.Logic
{
public class MusicPlayerLogic
{
readonly World world;
bool installed;
MusicInfo currentSong = null;
MusicInfo[] music;
@@ -26,9 +28,22 @@ namespace OpenRA.Mods.RA.Widgets.Logic
ScrollItemWidget itemTemplate;
[ObjectCreator.UseCtor]
public MusicPlayerLogic(Widget widget, Action onExit)
public static Widget OpenWindow(World world, Action onExit = null)
{
return Ui.OpenWindow(
"MUSIC_PANEL",
new WidgetArgs
{
{ "onExit", onExit != null ? onExit : (() => {}) }
}
);
}
[ObjectCreator.UseCtor]
public MusicPlayerLogic(Widget widget, World world, Action onExit)
{
this.world = world;
var panel = widget.Get("MUSIC_PANEL");
musicList = panel.Get<ScrollPanelWidget>("MUSIC_LIST");
@@ -82,7 +97,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
public void BuildMusicTable()
{
music = Rules.InstalledMusic.Select(a => a.Value).ToArray();
music = world.Map.Rules.InstalledMusic.Select(a => a.Value).ToArray();
random = music.Shuffle(Game.CosmeticRandom).ToArray();
currentSong = Sound.CurrentMusic;
if (currentSong == null && music.Any())
@@ -105,7 +120,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
if (currentSong != null)
musicList.ScrollToItem(currentSong.Filename);
installed = Rules.InstalledMusic.Any();
installed = world.Map.Rules.InstalledMusic.Any();
}
void Play()

View File

@@ -1,6 +1,6 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* Copyright 2007-2014 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,
@@ -315,10 +315,10 @@ namespace OpenRA.Mods.RA.Widgets.Logic
public static string GenerateModLabel(GameServer s)
{
Mod mod;
ModInformation mod;
var modVersion = s.Mods.Split('@');
if (modVersion.Length == 2 && Mod.AllMods.TryGetValue(modVersion[0], out mod))
if (modVersion.Length == 2 && ModInformation.AllMods.TryGetValue(modVersion[0], out mod))
return "{0} ({1})".F(mod.Title, modVersion[1]);
return "Unknown mod: {0}".F(s.Mods);

View File

@@ -1,6 +1,6 @@
#region Copyright & License Information
/*
* Copyright 2007-2012 The OpenRA Developers (see AUTHORS)
* Copyright 2007-2014 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,
@@ -21,8 +21,8 @@ namespace OpenRA.Mods.RA.Widgets
public class ObserverProductionIconsWidget : Widget
{
public Func<Player> GetPlayer;
World world;
WorldRenderer worldRenderer;
readonly World world;
readonly WorldRenderer worldRenderer;
Dictionary<ProductionQueue, Animation> clocks;
public int IconWidth = 32;

View File

@@ -1,6 +1,6 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* Copyright 2007-2014 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,
@@ -68,7 +68,7 @@ namespace OpenRA.Mods.RA.Widgets
mapRect = new Rectangle(previewOrigin.X, previewOrigin.Y, (int)(previewScale * width), (int)(previewScale * height));
// Only needs to be done once
var terrainBitmap = Minimap.TerrainBitmap(world.Map);
var terrainBitmap = Minimap.TerrainBitmap(world.Map.Rules.TileSets[world.Map.Tileset], world.Map);
var r = new Rectangle(0, 0, width, height);
var s = new Size(terrainBitmap.Width, terrainBitmap.Height);
terrainSprite = new Sprite(new Sheet(s), r, TextureChannel.Alpha);
@@ -99,7 +99,7 @@ namespace OpenRA.Mods.RA.Widgets
if (cursor == null)
return "default";
return CursorProvider.HasCursorSequence(cursor + "-minimap") ? cursor + "-minimap" : cursor;
return Game.modData.CursorProvider.HasCursorSequence(cursor + "-minimap") ? cursor + "-minimap" : cursor;
}
public override bool HandleMouseInput(MouseInput mi)