Remove static Game.ModData references from widget logic.
This commit is contained in:
@@ -49,6 +49,9 @@ namespace OpenRA
|
||||
if (!args.ContainsKey("modRules"))
|
||||
args = new WidgetArgs(args) { { "modRules", modData.DefaultRules } };
|
||||
|
||||
if (!args.ContainsKey("modData"))
|
||||
args = new WidgetArgs(args) { { "modData", modData } };
|
||||
|
||||
var widget = NewWidget(node.Key, args);
|
||||
|
||||
if (parent != null)
|
||||
|
||||
@@ -18,8 +18,8 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
|
||||
public class CncMainMenuLogic : MainMenuLogic
|
||||
{
|
||||
[ObjectCreator.UseCtor]
|
||||
public CncMainMenuLogic(Widget widget, World world)
|
||||
: base(widget, world)
|
||||
public CncMainMenuLogic(Widget widget, World world, ModData modData)
|
||||
: base(widget, world, modData)
|
||||
{
|
||||
var shellmapDecorations = widget.Get("SHELLMAP_DECORATIONS");
|
||||
shellmapDecorations.IsVisible = () => menuType != MenuType.None && Game.Settings.Game.ShowShellmap;
|
||||
|
||||
@@ -48,11 +48,10 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
int currentFrame;
|
||||
|
||||
[ObjectCreator.UseCtor]
|
||||
public AssetBrowserLogic(Widget widget, Action onExit, World world, Dictionary<string, MiniYaml> logicArgs)
|
||||
public AssetBrowserLogic(Widget widget, Action onExit, ModData modData, World world, Dictionary<string, MiniYaml> logicArgs)
|
||||
{
|
||||
this.world = world;
|
||||
modData = Game.ModData;
|
||||
|
||||
this.modData = modData;
|
||||
panel = widget;
|
||||
|
||||
var ticker = panel.GetOrNull<LogicTickerWidget>("ANIMATION_TICKER");
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
public class ColorPickerLogic : ChromeLogic
|
||||
{
|
||||
[ObjectCreator.UseCtor]
|
||||
public ColorPickerLogic(Widget widget, World world, HSLColor initialColor, Action<HSLColor> onChange, WorldRenderer worldRenderer)
|
||||
public ColorPickerLogic(Widget widget, ModData modData, World world, HSLColor initialColor, Action<HSLColor> onChange, WorldRenderer worldRenderer)
|
||||
{
|
||||
string actorType;
|
||||
if (!ChromeMetrics.TryGet("ColorPickerActorType", out actorType))
|
||||
@@ -57,7 +57,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
};
|
||||
|
||||
// Set the initial state
|
||||
var validator = Game.ModData.Manifest.Get<ColorValidator>();
|
||||
var validator = modData.Manifest.Get<ColorValidator>();
|
||||
mixer.SetPaletteRange(validator.HsvSaturationRange[0], validator.HsvSaturationRange[1], validator.HsvValueRange[0], validator.HsvValueRange[1]);
|
||||
mixer.Set(initialColor);
|
||||
|
||||
|
||||
@@ -18,10 +18,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
public class CreditsLogic : ChromeLogic
|
||||
{
|
||||
[ObjectCreator.UseCtor]
|
||||
public CreditsLogic(Widget widget, Action onExit)
|
||||
public CreditsLogic(Widget widget, ModData modData, Action onExit)
|
||||
{
|
||||
var panel = widget.Get("CREDITS_PANEL");
|
||||
var modData = Game.ModData;
|
||||
|
||||
panel.Get<ButtonWidget>("BACK_BUTTON").OnClick = () =>
|
||||
{
|
||||
|
||||
@@ -29,9 +29,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
}
|
||||
|
||||
[ObjectCreator.UseCtor]
|
||||
public SaveMapLogic(Widget widget, Action<string> onSave, Action onExit, Map map, List<MiniYamlNode> playerDefinitions, List<MiniYamlNode> actorDefinitions)
|
||||
public SaveMapLogic(Widget widget, ModData modData, Action<string> onSave, Action onExit,
|
||||
Map map, List<MiniYamlNode> playerDefinitions, List<MiniYamlNode> actorDefinitions)
|
||||
{
|
||||
var modData = Game.ModData;
|
||||
var title = widget.Get<TextFieldWidget>("TITLE");
|
||||
title.Text = map.Title;
|
||||
|
||||
|
||||
@@ -16,10 +16,10 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
class GameInfoBriefingLogic : ChromeLogic
|
||||
{
|
||||
[ObjectCreator.UseCtor]
|
||||
public GameInfoBriefingLogic(Widget widget, World world)
|
||||
public GameInfoBriefingLogic(Widget widget, ModData modData, World world)
|
||||
{
|
||||
var previewWidget = widget.Get<MapPreviewWidget>("MAP_PREVIEW");
|
||||
previewWidget.Preview = () => Game.ModData.MapCache[world.Map.Uid];
|
||||
previewWidget.Preview = () => modData.MapCache[world.Map.Uid];
|
||||
|
||||
var mapDescriptionPanel = widget.Get<ScrollPanelWidget>("MAP_DESCRIPTION_PANEL");
|
||||
var mapDescription = widget.Get<LabelWidget>("MAP_DESCRIPTION");
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
Widget menu;
|
||||
|
||||
[ObjectCreator.UseCtor]
|
||||
public IngameMenuLogic(Widget widget, World world, Action onExit, WorldRenderer worldRenderer, IngameInfoPanel activePanel)
|
||||
public IngameMenuLogic(Widget widget, ModData modData, World world, Action onExit, WorldRenderer worldRenderer, IngameInfoPanel activePanel)
|
||||
{
|
||||
var leaving = false;
|
||||
menu = widget.Get("INGAME_MENU");
|
||||
@@ -32,7 +32,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
if (mpe != null)
|
||||
mpe.Fade(mpe.Info.MenuEffect);
|
||||
|
||||
menu.Get<LabelWidget>("VERSION_LABEL").Text = Game.ModData.Manifest.Mod.Version;
|
||||
menu.Get<LabelWidget>("VERSION_LABEL").Text = modData.Manifest.Mod.Version;
|
||||
|
||||
var hideMenu = false;
|
||||
menu.Get("MENU_BUTTONS").IsVisible = () => !hideMenu;
|
||||
|
||||
@@ -20,6 +20,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
{
|
||||
public class InstallFromCDLogic : ChromeLogic
|
||||
{
|
||||
readonly ModData modData;
|
||||
readonly string modId;
|
||||
readonly Widget panel;
|
||||
readonly ProgressBarWidget progressBar;
|
||||
@@ -30,8 +31,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
readonly ContentInstaller installData;
|
||||
|
||||
[ObjectCreator.UseCtor]
|
||||
public InstallFromCDLogic(Widget widget, Action afterInstall, string modId)
|
||||
public InstallFromCDLogic(Widget widget, ModData modData, Action afterInstall, string modId)
|
||||
{
|
||||
this.modData = modData;
|
||||
this.modId = modId;
|
||||
installData = ModMetadata.AllMods[modId].Content;
|
||||
this.afterInstall = afterInstall;
|
||||
@@ -92,11 +94,10 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
insertDiskContainer.IsVisible = () => false;
|
||||
installingContainer.IsVisible = () => true;
|
||||
progressBar.Percentage = 0;
|
||||
var modData = Game.ModData;
|
||||
|
||||
new Thread(() =>
|
||||
{
|
||||
using (var cabExtractor = new InstallShieldCABExtractor(Game.ModData.ModFiles, source))
|
||||
using (var cabExtractor = new InstallShieldCABExtractor(modData.ModFiles, source))
|
||||
{
|
||||
var denom = installData.InstallShieldCABFileIds.Count;
|
||||
var extractFiles = installData.ExtractFilesFromCD;
|
||||
@@ -152,7 +153,6 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
retryButton.IsDisabled = () => true;
|
||||
insertDiskContainer.IsVisible = () => false;
|
||||
installingContainer.IsVisible = () => true;
|
||||
var modData = Game.ModData;
|
||||
var dest = Platform.ResolvePath("^", "Content", modId);
|
||||
var copyFiles = installData.CopyFilesFromCD;
|
||||
|
||||
|
||||
@@ -30,6 +30,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
public MapPreview MapPreview { get; private set; }
|
||||
public Map Map { get; private set; }
|
||||
|
||||
readonly ModData modData;
|
||||
readonly Action onStart;
|
||||
readonly Action onExit;
|
||||
readonly OrderManager orderManager;
|
||||
@@ -110,11 +111,12 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
}
|
||||
|
||||
[ObjectCreator.UseCtor]
|
||||
internal LobbyLogic(Widget widget, WorldRenderer worldRenderer, OrderManager orderManager,
|
||||
internal LobbyLogic(Widget widget, ModData modData, WorldRenderer worldRenderer, OrderManager orderManager,
|
||||
Action onExit, Action onStart, bool skirmishMode, Ruleset modRules)
|
||||
{
|
||||
MapPreview = MapCache.UnknownMap;
|
||||
lobby = widget;
|
||||
this.modData = modData;
|
||||
this.orderManager = orderManager;
|
||||
this.onStart = onStart;
|
||||
this.onExit = onExit;
|
||||
@@ -511,7 +513,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
var gameSpeed = optionsBin.GetOrNull<DropDownButtonWidget>("GAMESPEED_DROPDOWNBUTTON");
|
||||
if (gameSpeed != null)
|
||||
{
|
||||
var speeds = Game.ModData.Manifest.Get<GameSpeeds>().Speeds;
|
||||
var speeds = modData.Manifest.Get<GameSpeeds>().Speeds;
|
||||
|
||||
gameSpeed.IsDisabled = configurationDisabled;
|
||||
gameSpeed.GetText = () =>
|
||||
@@ -738,7 +740,6 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
if (MapPreview.Uid == uid)
|
||||
return;
|
||||
|
||||
var modData = Game.ModData;
|
||||
MapPreview = modData.MapCache[uid];
|
||||
Map = null;
|
||||
if (MapPreview.Status == MapStatus.Available)
|
||||
@@ -768,7 +769,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
}).Start();
|
||||
}
|
||||
else if (Game.Settings.Game.AllowDownloading)
|
||||
Game.ModData.MapCache.QueryRemoteMapDetails(new[] { uid });
|
||||
modData.MapCache.QueryRemoteMapDetails(new[] { uid });
|
||||
}
|
||||
|
||||
void UpdatePlayerList()
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
int blinkTick;
|
||||
|
||||
[ObjectCreator.UseCtor]
|
||||
internal LobbyMapPreviewLogic(Widget widget, OrderManager orderManager, LobbyLogic lobby)
|
||||
internal LobbyMapPreviewLogic(Widget widget, ModData modData, OrderManager orderManager, LobbyLogic lobby)
|
||||
{
|
||||
var available = widget.GetOrNull("MAP_AVAILABLE");
|
||||
if (available != null)
|
||||
@@ -162,7 +162,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
if (lobby.MapPreview.Status == MapStatus.DownloadError)
|
||||
lobby.MapPreview.Install();
|
||||
else if (lobby.MapPreview.Status == MapStatus.Unavailable)
|
||||
Game.ModData.MapCache.QueryRemoteMapDetails(new[] { lobby.MapPreview.Uid });
|
||||
modData.MapCache.QueryRemoteMapDetails(new[] { lobby.MapPreview.Uid });
|
||||
};
|
||||
|
||||
retry.GetText = () => lobby.MapPreview.Status == MapStatus.DownloadError ? "Retry Install" : "Retry Search";
|
||||
|
||||
@@ -41,10 +41,10 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
}
|
||||
|
||||
[ObjectCreator.UseCtor]
|
||||
public MainMenuLogic(Widget widget, World world)
|
||||
public MainMenuLogic(Widget widget, World world, ModData modData)
|
||||
{
|
||||
rootMenu = widget;
|
||||
rootMenu.Get<LabelWidget>("VERSION_LABEL").Text = Game.ModData.Manifest.Mod.Version;
|
||||
rootMenu.Get<LabelWidget>("VERSION_LABEL").Text = modData.Manifest.Mod.Version;
|
||||
|
||||
// Menu buttons
|
||||
var mainMenu = widget.Get("MAIN_MENU");
|
||||
@@ -70,7 +70,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
// so we can't do this inside the input handler.
|
||||
Game.RunAfterTick(() =>
|
||||
{
|
||||
Game.Settings.Game.PreviousMod = Game.ModData.Manifest.Mod.Id;
|
||||
Game.Settings.Game.PreviousMod = modData.Manifest.Mod.Id;
|
||||
Game.InitializeMod("modchooser", null);
|
||||
});
|
||||
};
|
||||
@@ -103,8 +103,8 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
});
|
||||
};
|
||||
|
||||
var hasCampaign = Game.ModData.Manifest.Missions.Any();
|
||||
var hasMissions = Game.ModData.MapCache
|
||||
var hasCampaign = modData.Manifest.Missions.Any();
|
||||
var hasMissions = modData.MapCache
|
||||
.Any(p => p.Status == MapStatus.Available && p.Visibility.HasFlag(MapVisibility.MissionSelector));
|
||||
|
||||
missionsButton.Disabled = !hasCampaign && !hasMissions;
|
||||
@@ -168,7 +168,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
var onSelect = new Action<string>(uid =>
|
||||
{
|
||||
RemoveShellmapUI();
|
||||
LoadMapIntoEditor(Game.ModData.MapCache[uid].Uid);
|
||||
LoadMapIntoEditor(modData.MapCache[uid].Uid);
|
||||
});
|
||||
|
||||
var newMapButton = widget.Get<ButtonWidget>("NEW_MAP_BUTTON");
|
||||
|
||||
@@ -23,6 +23,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
{
|
||||
readonly Widget widget;
|
||||
readonly DropDownButtonWidget gameModeDropdown;
|
||||
readonly ModData modData;
|
||||
|
||||
MapClassification currentTab;
|
||||
|
||||
@@ -38,9 +39,11 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
string mapFilter;
|
||||
|
||||
[ObjectCreator.UseCtor]
|
||||
internal MapChooserLogic(Widget widget, string initialMap, MapClassification initialTab, Action onExit, Action<string> onSelect, MapVisibility filter)
|
||||
internal MapChooserLogic(Widget widget, ModData modData, string initialMap,
|
||||
MapClassification initialTab, Action onExit, Action<string> onSelect, MapVisibility filter)
|
||||
{
|
||||
this.widget = widget;
|
||||
this.modData = modData;
|
||||
this.onSelect = onSelect;
|
||||
|
||||
var approving = new Action(() => { Ui.CloseWindow(); onSelect(selectedUid); });
|
||||
@@ -93,7 +96,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
}
|
||||
|
||||
var deleteMapButton = widget.Get<ButtonWidget>("DELETE_MAP_BUTTON");
|
||||
deleteMapButton.IsDisabled = () => Game.ModData.MapCache[selectedUid].Class != MapClassification.User;
|
||||
deleteMapButton.IsDisabled = () => modData.MapCache[selectedUid].Class != MapClassification.User;
|
||||
deleteMapButton.IsVisible = () => currentTab == MapClassification.User;
|
||||
deleteMapButton.OnClick = () =>
|
||||
{
|
||||
@@ -102,7 +105,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
RefreshMaps(currentTab, filter);
|
||||
EnumerateMaps(currentTab, itemTemplate);
|
||||
if (!tabMaps[currentTab].Any())
|
||||
SwitchTab(Game.ModData.MapCache[newUid].Class, itemTemplate);
|
||||
SwitchTab(modData.MapCache[newUid].Class, itemTemplate);
|
||||
});
|
||||
};
|
||||
|
||||
@@ -114,7 +117,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
{
|
||||
RefreshMaps(currentTab, filter);
|
||||
EnumerateMaps(currentTab, itemTemplate);
|
||||
SwitchTab(Game.ModData.MapCache[newUid].Class, itemTemplate);
|
||||
SwitchTab(modData.MapCache[newUid].Class, itemTemplate);
|
||||
});
|
||||
};
|
||||
|
||||
@@ -143,7 +146,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
|
||||
void RefreshMaps(MapClassification tab, MapVisibility filter)
|
||||
{
|
||||
tabMaps[tab] = Game.ModData.MapCache.Where(m => m.Status == MapStatus.Available &&
|
||||
tabMaps[tab] = modData.MapCache.Where(m => m.Status == MapStatus.Available &&
|
||||
m.Class == tab && (m.Visibility & filter) != 0).ToArray();
|
||||
}
|
||||
|
||||
@@ -285,7 +288,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
|
||||
string DeleteMap(string map)
|
||||
{
|
||||
var path = Game.ModData.MapCache[map].Package.Name;
|
||||
var path = modData.MapCache[map].Package.Name;
|
||||
try
|
||||
{
|
||||
if (File.Exists(path))
|
||||
@@ -293,7 +296,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
else if (Directory.Exists(path))
|
||||
Directory.Delete(path, true);
|
||||
|
||||
Game.ModData.MapCache[map].Invalidate();
|
||||
modData.MapCache[map].Invalidate();
|
||||
|
||||
if (selectedUid == map)
|
||||
selectedUid = WidgetUtils.ChooseInitialMap(tabMaps[currentTab].Select(mp => mp.Uid).FirstOrDefault());
|
||||
@@ -311,7 +314,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
{
|
||||
ConfirmationDialogs.PromptConfirmAction(
|
||||
title: "Delete map",
|
||||
text: "Delete the map '{0}'?".F(Game.ModData.MapCache[map].Title),
|
||||
text: "Delete the map '{0}'?".F(modData.MapCache[map].Title),
|
||||
onConfirm: () =>
|
||||
{
|
||||
var newUid = DeleteMap(map);
|
||||
|
||||
@@ -53,10 +53,10 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
string gameSpeed;
|
||||
|
||||
[ObjectCreator.UseCtor]
|
||||
public MissionBrowserLogic(Widget widget, World world, Action onStart, Action onExit)
|
||||
public MissionBrowserLogic(Widget widget, ModData modData, World world, Action onStart, Action onExit)
|
||||
{
|
||||
modData = Game.ModData;
|
||||
mapCache = new Cache<MapPreview, Map>(p => new Map(modData, p.Package));
|
||||
this.modData = modData;
|
||||
this.onStart = onStart;
|
||||
|
||||
missionList = widget.Get<ScrollPanelWidget>("MISSION_LIST");
|
||||
@@ -230,7 +230,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
|
||||
if (gameSpeedButton != null)
|
||||
{
|
||||
var speeds = Game.ModData.Manifest.Get<GameSpeeds>().Speeds;
|
||||
var speeds = modData.Manifest.Get<GameSpeeds>().Speeds;
|
||||
gameSpeed = "default";
|
||||
|
||||
gameSpeedButton.GetText = () => speeds[gameSpeed].Name;
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
int modOffset = 0;
|
||||
|
||||
[ObjectCreator.UseCtor]
|
||||
public ModBrowserLogic(Widget widget)
|
||||
public ModBrowserLogic(Widget widget, ModData modData)
|
||||
{
|
||||
modInstallStatus = new Cache<ModMetadata, bool>(IsModInstalled);
|
||||
modPrerequisitesFulfilled = new Cache<string, bool>(Game.IsModInstalled);
|
||||
@@ -46,7 +46,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
modChooserPanel = widget;
|
||||
loadButton = modChooserPanel.Get<ButtonWidget>("LOAD_BUTTON");
|
||||
loadButton.OnClick = () => LoadMod(selectedMod);
|
||||
loadButton.IsDisabled = () => selectedMod.Id == Game.ModData.Manifest.Mod.Id;
|
||||
loadButton.IsDisabled = () => selectedMod.Id == modData.Manifest.Mod.Id;
|
||||
|
||||
modChooserPanel.Get<ButtonWidget>("QUIT_BUTTON").OnClick = Game.Exit;
|
||||
|
||||
|
||||
@@ -36,6 +36,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
readonly Color incompatibleGameStartedColor;
|
||||
readonly Color gameStartedColor;
|
||||
readonly Color incompatibleGameColor;
|
||||
readonly ModData modData;
|
||||
|
||||
GameServer currentServer;
|
||||
MapPreview currentMap;
|
||||
@@ -68,8 +69,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
}
|
||||
|
||||
[ObjectCreator.UseCtor]
|
||||
public MultiplayerLogic(Widget widget, Action onStart, Action onExit, string directConnectHost, int directConnectPort)
|
||||
public MultiplayerLogic(Widget widget, ModData modData, Action onStart, Action onExit, string directConnectHost, int directConnectPort)
|
||||
{
|
||||
this.modData = modData;
|
||||
this.onStart = onStart;
|
||||
this.onExit = onExit;
|
||||
|
||||
@@ -321,7 +323,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
return 0;
|
||||
|
||||
// Games for the current mod+version are sorted first
|
||||
if (testEntry.ModId == Game.ModData.Manifest.Mod.Id)
|
||||
if (testEntry.ModId == modData.Manifest.Mod.Id)
|
||||
return 2;
|
||||
|
||||
// Followed by games for different mods that are joinable
|
||||
@@ -331,7 +333,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
void SelectServer(GameServer server)
|
||||
{
|
||||
currentServer = server;
|
||||
currentMap = server != null ? Game.ModData.MapCache[server.Map] : null;
|
||||
currentMap = server != null ? modData.MapCache[server.Map] : null;
|
||||
}
|
||||
|
||||
void RefreshServerListInner(IEnumerable<GameServer> games)
|
||||
@@ -438,7 +440,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
|
||||
// Search for any unknown maps
|
||||
if (Game.Settings.Game.AllowDownloading)
|
||||
Game.ModData.MapCache.QueryRemoteMapDetails(games.Where(g => !Filtered(g)).Select(g => g.Map));
|
||||
modData.MapCache.QueryRemoteMapDetails(games.Where(g => !Filtered(g)).Select(g => g.Map));
|
||||
|
||||
foreach (var row in rows)
|
||||
serverList.AddChild(row);
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
MusicInfo currentSong = null;
|
||||
|
||||
[ObjectCreator.UseCtor]
|
||||
public MusicPlayerLogic(Widget widget, Ruleset modRules, World world, Action onExit)
|
||||
public MusicPlayerLogic(Widget widget, ModData modData, Ruleset modRules, World world, Action onExit)
|
||||
{
|
||||
var panel = widget;
|
||||
|
||||
@@ -107,11 +107,11 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
if (installButton != null)
|
||||
{
|
||||
installButton.IsDisabled = () => world.Type != WorldType.Shellmap;
|
||||
var args = new[] { "installMusic={0}".F(Game.ModData.Manifest.Mod.Id) };
|
||||
var args = new[] { "installMusic={0}".F(modData.Manifest.Mod.Id) };
|
||||
installButton.OnClick = () =>
|
||||
Game.RunAfterTick(() => Game.InitializeMod("modchooser", new Arguments(args)));
|
||||
|
||||
var installData = Game.ModData.Manifest.Get<ContentInstaller>();
|
||||
var installData = modData.Manifest.Get<ContentInstaller>();
|
||||
installButton.IsVisible = () => modRules.InstalledMusic.ToArray().Length <= installData.ShippedSoundtracks;
|
||||
}
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
volatile bool cancelLoadingReplays;
|
||||
|
||||
[ObjectCreator.UseCtor]
|
||||
public ReplayBrowserLogic(Widget widget, Action onExit, Action onStart)
|
||||
public ReplayBrowserLogic(Widget widget, ModData modData, Action onExit, Action onStart)
|
||||
{
|
||||
panel = widget;
|
||||
|
||||
@@ -55,7 +55,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
replayList = panel.Get<ScrollPanelWidget>("REPLAY_LIST");
|
||||
var template = panel.Get<ScrollItemWidget>("REPLAY_TEMPLATE");
|
||||
|
||||
var mod = Game.ModData.Manifest.Mod;
|
||||
var mod = modData.Manifest.Mod;
|
||||
var dir = Platform.ResolvePath("^", "Replays", mod.Id, mod.Version);
|
||||
|
||||
if (Directory.Exists(dir))
|
||||
|
||||
@@ -25,14 +25,14 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
bool allowPortForward;
|
||||
|
||||
[ObjectCreator.UseCtor]
|
||||
public ServerCreationLogic(Widget widget, Action onExit, Action openLobby)
|
||||
public ServerCreationLogic(Widget widget, ModData modData, Action onExit, Action openLobby)
|
||||
{
|
||||
panel = widget;
|
||||
onCreate = openLobby;
|
||||
this.onExit = onExit;
|
||||
|
||||
var settings = Game.Settings;
|
||||
preview = Game.ModData.MapCache[WidgetUtils.ChooseInitialMap(Game.Settings.Server.Map)];
|
||||
preview = modData.MapCache[WidgetUtils.ChooseInitialMap(Game.Settings.Server.Map)];
|
||||
|
||||
panel.Get<ButtonWidget>("CREATE_BUTTON").OnClick = CreateAndJoin;
|
||||
|
||||
@@ -46,7 +46,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
{ "initialMap", preview.Uid },
|
||||
{ "initialTab", MapClassification.System },
|
||||
{ "onExit", () => { } },
|
||||
{ "onSelect", (Action<string>)(uid => preview = Game.ModData.MapCache[uid]) },
|
||||
{ "onSelect", (Action<string>)(uid => preview = modData.MapCache[uid]) },
|
||||
{ "filter", MapVisibility.Lobby },
|
||||
{ "onStart", () => { } }
|
||||
});
|
||||
|
||||
@@ -21,13 +21,6 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
public class SettingsLogic : ChromeLogic
|
||||
{
|
||||
enum PanelType { Display, Audio, Input, Advanced }
|
||||
Dictionary<PanelType, Action> leavePanelActions = new Dictionary<PanelType, Action>();
|
||||
Dictionary<PanelType, Action> resetPanelActions = new Dictionary<PanelType, Action>();
|
||||
PanelType settingsPanel = PanelType.Display;
|
||||
Widget panelContainer, tabContainer;
|
||||
|
||||
WorldRenderer worldRenderer;
|
||||
SoundDevice soundDevice;
|
||||
|
||||
static readonly string OriginalSoundDevice;
|
||||
static readonly string OriginalSoundEngine;
|
||||
@@ -36,6 +29,16 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
static readonly int2 OriginalGraphicsWindowedSize;
|
||||
static readonly int2 OriginalGraphicsFullscreenSize;
|
||||
|
||||
readonly Dictionary<PanelType, Action> leavePanelActions = new Dictionary<PanelType, Action>();
|
||||
readonly Dictionary<PanelType, Action> resetPanelActions = new Dictionary<PanelType, Action>();
|
||||
readonly Widget panelContainer, tabContainer;
|
||||
|
||||
readonly ModData modData;
|
||||
readonly WorldRenderer worldRenderer;
|
||||
|
||||
SoundDevice soundDevice;
|
||||
PanelType settingsPanel = PanelType.Display;
|
||||
|
||||
static SettingsLogic()
|
||||
{
|
||||
var original = Game.Settings;
|
||||
@@ -48,9 +51,10 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
}
|
||||
|
||||
[ObjectCreator.UseCtor]
|
||||
public SettingsLogic(Widget widget, Action onExit, WorldRenderer worldRenderer)
|
||||
public SettingsLogic(Widget widget, Action onExit, ModData modData, WorldRenderer worldRenderer)
|
||||
{
|
||||
this.worldRenderer = worldRenderer;
|
||||
this.modData = modData;
|
||||
|
||||
panelContainer = widget.Get("SETTINGS_PANEL");
|
||||
tabContainer = widget.Get("TAB_CONTAINER");
|
||||
@@ -158,7 +162,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
BindCheckboxPref(panel, "PLAYER_STANCE_COLORS_CHECKBOX", gs, "UsePlayerStanceColors");
|
||||
|
||||
var languageDropDownButton = panel.Get<DropDownButtonWidget>("LANGUAGE_DROPDOWNBUTTON");
|
||||
languageDropDownButton.OnMouseDown = _ => ShowLanguageDropdown(languageDropDownButton);
|
||||
languageDropDownButton.OnMouseDown = _ => ShowLanguageDropdown(languageDropDownButton, modData.Languages);
|
||||
languageDropDownButton.GetText = () => FieldLoader.Translate(ds.Language);
|
||||
|
||||
var windowModeDropdown = panel.Get<DropDownButtonWidget>("MODE_DROPDOWN");
|
||||
@@ -684,7 +688,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool ShowLanguageDropdown(DropDownButtonWidget dropdown)
|
||||
static bool ShowLanguageDropdown(DropDownButtonWidget dropdown, IEnumerable<string> languages)
|
||||
{
|
||||
Func<string, ScrollItemWidget, ScrollItemWidget> setupItem = (o, itemTemplate) =>
|
||||
{
|
||||
@@ -696,7 +700,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
return item;
|
||||
};
|
||||
|
||||
dropdown.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 500, Game.ModData.Languages, setupItem);
|
||||
dropdown.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 500, languages, setupItem);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user