Double clicking a map in the chooser now selects it.
This commit is contained in:
@@ -65,9 +65,10 @@ namespace OpenRA.Widgets
|
|||||||
return w;
|
return w;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ScrollItemWidget Setup(string key, ScrollItemWidget template, Func<bool> isSelected, Action onClick)
|
public static ScrollItemWidget Setup(string key, ScrollItemWidget template, Func<bool> isSelected, Action onClick, Action onDoubleClick)
|
||||||
{
|
{
|
||||||
var w = Setup(template, isSelected, onClick);
|
var w = Setup(template, isSelected, onClick);
|
||||||
|
w.OnDoubleClick = onDoubleClick;
|
||||||
w.ItemKey = key;
|
w.ItemKey = key;
|
||||||
return w;
|
return w;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
{
|
{
|
||||||
var item = ScrollItemWidget.Setup(template,
|
var item = ScrollItemWidget.Setup(template,
|
||||||
() => gameMode == ii.First,
|
() => gameMode == ii.First,
|
||||||
() => { gameMode = ii.First; EnumerateMaps(); });
|
() => { gameMode = ii.First; EnumerateMaps(onSelect); });
|
||||||
item.Get<LabelWidget>("LABEL").GetText = () => showItem(ii);
|
item.Get<LabelWidget>("LABEL").GetText = () => showItem(ii);
|
||||||
return item;
|
return item;
|
||||||
};
|
};
|
||||||
@@ -83,10 +83,10 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
randomMapButton.IsDisabled = () => visibleMaps == null || visibleMaps.Count == 0;
|
randomMapButton.IsDisabled = () => visibleMaps == null || visibleMaps.Count == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
EnumerateMaps();
|
EnumerateMaps(onSelect);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EnumerateMaps()
|
void EnumerateMaps(Action<Map> onSelect)
|
||||||
{
|
{
|
||||||
var maps = Game.modData.AvailableMaps
|
var maps = Game.modData.AvailableMaps
|
||||||
.Where(kv => kv.Value.Selectable)
|
.Where(kv => kv.Value.Selectable)
|
||||||
@@ -98,7 +98,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
foreach (var kv in maps)
|
foreach (var kv in maps)
|
||||||
{
|
{
|
||||||
var m = kv.Value;
|
var m = kv.Value;
|
||||||
var item = ScrollItemWidget.Setup(kv.Key, itemTemplate, () => m == map, () => map = m);
|
var item = ScrollItemWidget.Setup(kv.Key, itemTemplate, () => m == map, () => map = m, () => { Ui.CloseWindow(); onSelect(m); });
|
||||||
|
|
||||||
var titleLabel = item.Get<LabelWidget>("TITLE");
|
var titleLabel = item.Get<LabelWidget>("TITLE");
|
||||||
titleLabel.GetText = () => m.Title;
|
titleLabel.GetText = () => m.Title;
|
||||||
|
|||||||
@@ -98,7 +98,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
currentSong = song;
|
currentSong = song;
|
||||||
|
|
||||||
// TODO: We leak the currentSong MusicInfo across map load, so compare the Filename instead.
|
// TODO: We leak the currentSong MusicInfo across map load, so compare the Filename instead.
|
||||||
var item = ScrollItemWidget.Setup(song.Filename, itemTemplate, () => currentSong.Filename == song.Filename, () => { currentSong = song; Play(); });
|
var item = ScrollItemWidget.Setup(song.Filename, itemTemplate, () => currentSong.Filename == song.Filename, () => { currentSong = song; Play(); }, () => {});
|
||||||
item.Get<LabelWidget>("TITLE").GetText = () => song.Title;
|
item.Get<LabelWidget>("TITLE").GetText = () => song.Title;
|
||||||
item.Get<LabelWidget>("LENGTH").GetText = () => SongLengthLabel(song);
|
item.Get<LabelWidget>("LENGTH").GetText = () => SongLengthLabel(song);
|
||||||
musicList.AddChild(item);
|
musicList.AddChild(item);
|
||||||
|
|||||||
Reference in New Issue
Block a user