Add dynamic map refresh
This commit is contained in:
committed by
Matthias Mailänder
parent
61df7974b0
commit
b254eb0f3d
@@ -1,6 +1,6 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2021 The OpenRA Developers (see AUTHORS)
|
||||
* Copyright 2007-2022 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, either version 3 of
|
||||
@@ -119,7 +119,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
|
||||
if (previews.Any())
|
||||
{
|
||||
CreateMissionGroup(kv.Key, previews);
|
||||
CreateMissionGroup(kv.Key, previews, onExit);
|
||||
allPreviews.AddRange(previews);
|
||||
}
|
||||
}
|
||||
@@ -131,7 +131,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
|
||||
if (loosePreviews.Any())
|
||||
{
|
||||
CreateMissionGroup("Missions", loosePreviews);
|
||||
CreateMissionGroup("Missions", loosePreviews, onExit);
|
||||
allPreviews.AddRange(loosePreviews);
|
||||
}
|
||||
|
||||
@@ -146,7 +146,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
}).Start();
|
||||
|
||||
var startButton = widget.Get<ButtonWidget>("STARTGAME_BUTTON");
|
||||
startButton.OnClick = StartMissionClicked;
|
||||
startButton.OnClick = () => StartMissionClicked(onExit);
|
||||
startButton.IsDisabled = () => selectedMap == null;
|
||||
|
||||
widget.Get<ButtonWidget>("BACK_BUTTON").OnClick = () =>
|
||||
@@ -179,7 +179,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
void CreateMissionGroup(string title, IEnumerable<MapPreview> previews)
|
||||
void CreateMissionGroup(string title, IEnumerable<MapPreview> previews, Action onExit)
|
||||
{
|
||||
var header = ScrollItemWidget.Setup(headerTemplate, () => true, () => { });
|
||||
header.Get<LabelWidget>("LABEL").GetText = () => title;
|
||||
@@ -190,7 +190,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
var item = ScrollItemWidget.Setup(template,
|
||||
() => selectedMap != null && selectedMap.Uid == preview.Uid,
|
||||
() => SelectMap(preview),
|
||||
StartMissionClicked);
|
||||
() => StartMissionClicked(onExit));
|
||||
|
||||
var label = item.Get<LabelWithTooltipWidget>("TITLE");
|
||||
WidgetUtils.TruncateLabelToTooltip(label, preview.Title);
|
||||
@@ -365,10 +365,19 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
playingVideo = PlayingVideo.None;
|
||||
}
|
||||
|
||||
void StartMissionClicked()
|
||||
void StartMissionClicked(Action onExit)
|
||||
{
|
||||
StopVideo(videoPlayer);
|
||||
|
||||
// If selected mission becomes unavailable, exit MissionBrowser to refresh
|
||||
if (modData.MapCache[selectedMap.Uid].Status != MapStatus.Available)
|
||||
{
|
||||
Game.Disconnect();
|
||||
Ui.CloseWindow();
|
||||
onExit();
|
||||
return;
|
||||
}
|
||||
|
||||
var orders = new List<Order>();
|
||||
if (difficulty != null)
|
||||
orders.Add(Order.Command($"option difficulty {difficulty}"));
|
||||
|
||||
Reference in New Issue
Block a user