Move web urls from user config to mod config.

This commit is contained in:
Paul Chote
2017-04-17 09:42:49 +00:00
parent 04f5937476
commit 1722f42f83
11 changed files with 54 additions and 23 deletions

View File

@@ -36,6 +36,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
readonly bool skirmishMode;
readonly Ruleset modRules;
readonly World shellmapWorld;
readonly WebServices services;
enum PanelType { Players, Options, Music, Kick, ForceStart }
PanelType panel = PanelType.Players;
@@ -117,6 +118,8 @@ namespace OpenRA.Mods.Common.Widgets.Logic
this.modRules = modData.DefaultRules;
shellmapWorld = worldRenderer.World;
services = modData.Manifest.Get<WebServices>();
orderManager.AddChatLine += AddChatLine;
Game.LobbyInfoChanged += UpdateCurrentMap;
Game.LobbyInfoChanged += UpdatePlayerList;
@@ -655,7 +658,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
else if (Map.Status == MapStatus.DownloadAvailable)
LoadMapPreviewRules(Map);
else if (Game.Settings.Game.AllowDownloading)
modData.MapCache.QueryRemoteMapDetails(new[] { uid }, LoadMapPreviewRules);
modData.MapCache.QueryRemoteMapDetails(services.MapRepository, new[] { uid }, LoadMapPreviewRules);
}
void UpdatePlayerList()

View File

@@ -24,6 +24,8 @@ namespace OpenRA.Mods.Common.Widgets.Logic
[ObjectCreator.UseCtor]
internal LobbyMapPreviewLogic(Widget widget, ModData modData, OrderManager orderManager, LobbyLogic lobby)
{
var mapRepository = modData.Manifest.Get<WebServices>().MapRepository;
var available = widget.GetOrNull("MAP_AVAILABLE");
if (available != null)
{
@@ -109,11 +111,12 @@ namespace OpenRA.Mods.Common.Widgets.Logic
var install = download.GetOrNull<ButtonWidget>("MAP_INSTALL");
if (install != null)
{
install.OnClick = () => lobby.Map.Install(() =>
install.OnClick = () => lobby.Map.Install(mapRepository, () =>
{
lobby.Map.PreloadRules();
Game.RunAfterTick(() => orderManager.IssueOrder(Order.Command("state {0}".F(Session.ClientState.NotReady))));
});
install.IsHighlighted = () => installHighlighted;
}
}
@@ -178,9 +181,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic
retry.OnClick = () =>
{
if (lobby.Map.Status == MapStatus.DownloadError)
lobby.Map.Install(() => orderManager.IssueOrder(Order.Command("state {0}".F(Session.ClientState.NotReady))));
lobby.Map.Install(mapRepository, () => orderManager.IssueOrder(Order.Command("state {0}".F(Session.ClientState.NotReady))));
else if (lobby.Map.Status == MapStatus.Unavailable)
modData.MapCache.QueryRemoteMapDetails(new[] { lobby.Map.Uid });
modData.MapCache.QueryRemoteMapDetails(mapRepository, new[] { lobby.Map.Uid });
};
retry.GetText = () => lobby.Map.Status == MapStatus.DownloadError ? "Retry Install" : "Retry Search";

View File

@@ -235,6 +235,8 @@ namespace OpenRA.Mods.Common.Widgets.Logic
Game.OnRemoteDirectConnect += OnRemoteDirectConnect;
var newsURL = modData.Manifest.Get<WebServices>().GameNews;
// System information opt-out prompt
var sysInfoPrompt = widget.Get("SYSTEM_INFO_PROMPT");
sysInfoPrompt.IsVisible = () => menuType == MenuType.SystemInfoPrompt;
@@ -263,14 +265,14 @@ namespace OpenRA.Mods.Common.Widgets.Logic
Game.Settings.Debug.SystemInformationVersionPrompt = SystemInformationVersion;
Game.Settings.Save();
SwitchMenu(MenuType.Main);
LoadAndDisplayNews(newsBG);
LoadAndDisplayNews(newsURL, newsBG);
};
}
else
LoadAndDisplayNews(newsBG);
LoadAndDisplayNews(newsURL, newsBG);
}
void LoadAndDisplayNews(Widget newsBG)
void LoadAndDisplayNews(string newsURL, Widget newsBG)
{
if (newsBG != null)
{
@@ -285,7 +287,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
if (!fetchedNews)
{
// Send the mod and engine version to support version-filtered news (update prompts)
var newsURL = Game.Settings.Game.NewsUrl + "?version={0}&mod={1}&modversion={2}".F(
newsURL += "?version={0}&mod={1}&modversion={2}".F(
Uri.EscapeUriString(Game.Mods["modchooser"].Metadata.Version),
Uri.EscapeUriString(Game.ModData.Manifest.Id),
Uri.EscapeUriString(Game.ModData.Manifest.Metadata.Version));

View File

@@ -38,6 +38,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
readonly Color gameStartedColor;
readonly Color incompatibleGameColor;
readonly ModData modData;
readonly WebServices services;
GameServer currentServer;
MapPreview currentMap;
@@ -70,6 +71,8 @@ namespace OpenRA.Mods.Common.Widgets.Logic
this.onStart = onStart;
this.onExit = onExit;
services = modData.Manifest.Get<WebServices>();
incompatibleVersionColor = ChromeMetrics.Get<Color>("IncompatibleVersionColor");
incompatibleGameColor = ChromeMetrics.Get<Color>("IncompatibleGameColor");
incompatibleProtectedGameColor = ChromeMetrics.Get<Color>("IncompatibleProtectedGameColor");
@@ -322,7 +325,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
Game.RunAfterTick(() => RefreshServerListInner(games));
};
var queryURL = Game.Settings.Server.MasterServer + "games?version={0}&mod={1}&modversion={2}".F(
var queryURL = services.ServerList + "games?version={0}&mod={1}&modversion={2}".F(
Uri.EscapeUriString(Game.Mods["modchooser"].Metadata.Version),
Uri.EscapeUriString(Game.ModData.Manifest.Id),
Uri.EscapeUriString(Game.ModData.Manifest.Metadata.Version));
@@ -476,7 +479,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
// Search for any unknown maps
if (Game.Settings.Game.AllowDownloading)
modData.MapCache.QueryRemoteMapDetails(games.Where(g => !Filtered(g)).Select(g => g.Map));
modData.MapCache.QueryRemoteMapDetails(services.MapRepository, games.Where(g => !Filtered(g)).Select(g => g.Map));
foreach (var row in rows)
serverList.AddChild(row);