start reducing differences between cnc and ra mapchoosers
This commit is contained in:
@@ -221,6 +221,15 @@ namespace OpenRA.Widgets
|
|||||||
var mod = Game.modData.Manifest.Mods[0];
|
var mod = Game.modData.Manifest.Mods[0];
|
||||||
return Mod.AllMods[mod].Title;
|
return Mod.AllMods[mod].Title;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static string ChooseInitialMap(string map)
|
||||||
|
{
|
||||||
|
var availableMaps = Game.modData.AvailableMaps;
|
||||||
|
if (string.IsNullOrEmpty(map) || !availableMaps.ContainsKey(map))
|
||||||
|
return availableMaps.First(m => m.Value.Selectable).Key;
|
||||||
|
|
||||||
|
return map;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[Flags]
|
[Flags]
|
||||||
|
|||||||
@@ -17,15 +17,6 @@ namespace OpenRA.Mods.Cnc.Widgets
|
|||||||
{
|
{
|
||||||
public static class CncWidgetUtils
|
public static class CncWidgetUtils
|
||||||
{
|
{
|
||||||
public static string ChooseInitialMap(string map)
|
|
||||||
{
|
|
||||||
var availableMaps = Game.modData.AvailableMaps;
|
|
||||||
if (string.IsNullOrEmpty(map) || !availableMaps.ContainsKey(map))
|
|
||||||
return availableMaps.First(m => m.Value.Selectable).Key;
|
|
||||||
|
|
||||||
return map;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void PromptConfirmAction(string title, string text, Action onConfirm, Action onCancel)
|
public static void PromptConfirmAction(string title, string text, Action onConfirm, Action onCancel)
|
||||||
{
|
{
|
||||||
var prompt = Widget.OpenWindow("CONFIRM_PROMPT");
|
var prompt = Widget.OpenWindow("CONFIRM_PROMPT");
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
|
|||||||
[ObjectCreator.Param] Action onExit,
|
[ObjectCreator.Param] Action onExit,
|
||||||
[ObjectCreator.Param] Action<Map> onSelect)
|
[ObjectCreator.Param] Action<Map> onSelect)
|
||||||
{
|
{
|
||||||
map = Game.modData.AvailableMaps[ CncWidgetUtils.ChooseInitialMap(initialMap) ];
|
map = Game.modData.AvailableMaps[ WidgetUtils.ChooseInitialMap(initialMap) ];
|
||||||
|
|
||||||
var panel = widget.GetWidget("MAPCHOOSER_PANEL");
|
var panel = widget.GetWidget("MAPCHOOSER_PANEL");
|
||||||
|
|
||||||
|
|||||||
@@ -143,7 +143,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
|
|||||||
|
|
||||||
void StartSkirmishGame()
|
void StartSkirmishGame()
|
||||||
{
|
{
|
||||||
var map = CncWidgetUtils.ChooseInitialMap(Game.Settings.Server.Map);
|
var map = WidgetUtils.ChooseInitialMap(Game.Settings.Server.Map);
|
||||||
|
|
||||||
CncConnectingLogic.Connect(IPAddress.Loopback.ToString(),
|
CncConnectingLogic.Connect(IPAddress.Loopback.ToString(),
|
||||||
Game.CreateLocalServer(map),
|
Game.CreateLocalServer(map),
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
map = Game.modData.AvailableMaps[ CncWidgetUtils.ChooseInitialMap(Game.Settings.Server.Map) ];
|
map = Game.modData.AvailableMaps[ WidgetUtils.ChooseInitialMap(Game.Settings.Server.Map) ];
|
||||||
|
|
||||||
panel.GetWidget<MapPreviewWidget>("MAP_PREVIEW").Map = () => map;
|
panel.GetWidget<MapPreviewWidget>("MAP_PREVIEW").Map = () => map;
|
||||||
panel.GetWidget<LabelWidget>("MAP_NAME").GetText = () => map.Title;
|
panel.GetWidget<LabelWidget>("MAP_NAME").GetText = () => map.Title;
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
else
|
else
|
||||||
Map = Game.modData.AvailableMaps.FirstOrDefault(m => m.Value.Selectable).Value;
|
Map = Game.modData.AvailableMaps.FirstOrDefault(m => m.Value.Selectable).Value;
|
||||||
|
|
||||||
bg.GetWidget<MapPreviewWidget>("MAPCHOOSER_MAP_PREVIEW").Map = () => Map;
|
bg.GetWidget<MapPreviewWidget>("MAP_PREVIEW").Map = () => Map;
|
||||||
bg.GetWidget<LabelWidget>("CURMAP_TITLE").GetText = () => Map.Title;
|
bg.GetWidget<LabelWidget>("CURMAP_TITLE").GetText = () => Map.Title;
|
||||||
bg.GetWidget<LabelWidget>("CURMAP_AUTHOR").GetText = () => Map.Author;
|
bg.GetWidget<LabelWidget>("CURMAP_AUTHOR").GetText = () => Map.Author;
|
||||||
bg.GetWidget<LabelWidget>("CURMAP_DESC").GetText = () => Map.Description;
|
bg.GetWidget<LabelWidget>("CURMAP_DESC").GetText = () => Map.Description;
|
||||||
|
|||||||
@@ -78,8 +78,8 @@ Background@MAP_CHOOSER:
|
|||||||
Height:252
|
Height:252
|
||||||
Background:dialog3
|
Background:dialog3
|
||||||
Children:
|
Children:
|
||||||
MapPreview@MAPCHOOSER_MAP_PREVIEW:
|
MapPreview@MAP_PREVIEW:
|
||||||
Id:MAPCHOOSER_MAP_PREVIEW
|
Id:MAP_PREVIEW
|
||||||
X:4
|
X:4
|
||||||
Y:4
|
Y:4
|
||||||
Width:244
|
Width:244
|
||||||
|
|||||||
Reference in New Issue
Block a user