Add dropdown for sorting maps in map chooser dialog
This commit is contained in:
3
AUTHORS
3
AUTHORS
@@ -37,6 +37,7 @@ Also thanks to:
|
|||||||
* Arik Lirette (Angusm3)
|
* Arik Lirette (Angusm3)
|
||||||
* Barnaby Smith (mvi)
|
* Barnaby Smith (mvi)
|
||||||
* Bellator
|
* Bellator
|
||||||
|
* Bernd Stellwag (burned42)
|
||||||
* Biofreak
|
* Biofreak
|
||||||
* Braxton Williams (Buddytex)
|
* Braxton Williams (Buddytex)
|
||||||
* Brendan Gluth (Mechanical_Man)
|
* Brendan Gluth (Mechanical_Man)
|
||||||
@@ -46,6 +47,7 @@ Also thanks to:
|
|||||||
* Chris Cameron (Vesuvian)
|
* Chris Cameron (Vesuvian)
|
||||||
* Chris Grant (Unit158)
|
* Chris Grant (Unit158)
|
||||||
* Christer Ulfsparre (Holloweye)
|
* Christer Ulfsparre (Holloweye)
|
||||||
|
* Christoph Lahner (chlah)
|
||||||
* clem
|
* clem
|
||||||
* Cody Brittain (Generalcamo)
|
* Cody Brittain (Generalcamo)
|
||||||
* Constantin Helmig (CH4Code)
|
* Constantin Helmig (CH4Code)
|
||||||
@@ -143,6 +145,7 @@ Also thanks to:
|
|||||||
* Stuart McHattie (SDJMcHattie)
|
* Stuart McHattie (SDJMcHattie)
|
||||||
* Taryn Hill (Phrohdoh)
|
* Taryn Hill (Phrohdoh)
|
||||||
* Teemu Nieminen (Temeez)
|
* Teemu Nieminen (Temeez)
|
||||||
|
* Thomas Christlieb (ThomasChr)
|
||||||
* Tim Mylemans (gecko)
|
* Tim Mylemans (gecko)
|
||||||
* Tirili
|
* Tirili
|
||||||
* Tomas Einarsson (Mesacer)
|
* Tomas Einarsson (Mesacer)
|
||||||
|
|||||||
@@ -80,6 +80,7 @@ namespace OpenRA
|
|||||||
public MapStatus Status;
|
public MapStatus Status;
|
||||||
public MapClassification Class;
|
public MapClassification Class;
|
||||||
public MapVisibility Visibility;
|
public MapVisibility Visibility;
|
||||||
|
public DateTime ModifiedDate;
|
||||||
|
|
||||||
public MiniYaml RuleDefinitions;
|
public MiniYaml RuleDefinitions;
|
||||||
public MiniYaml WeaponDefinitions;
|
public MiniYaml WeaponDefinitions;
|
||||||
@@ -187,6 +188,7 @@ namespace OpenRA
|
|||||||
|
|
||||||
public ActorInfo WorldActorInfo => innerData.WorldActorInfo;
|
public ActorInfo WorldActorInfo => innerData.WorldActorInfo;
|
||||||
public ActorInfo PlayerActorInfo => innerData.PlayerActorInfo;
|
public ActorInfo PlayerActorInfo => innerData.PlayerActorInfo;
|
||||||
|
public DateTime ModifiedDate => innerData.ModifiedDate;
|
||||||
|
|
||||||
public long DownloadBytes { get; private set; }
|
public long DownloadBytes { get; private set; }
|
||||||
public int DownloadPercentage { get; private set; }
|
public int DownloadPercentage { get; private set; }
|
||||||
@@ -395,6 +397,8 @@ namespace OpenRA
|
|||||||
using (var dataStream = p.GetStream("map.png"))
|
using (var dataStream = p.GetStream("map.png"))
|
||||||
newData.Preview = new Png(dataStream);
|
newData.Preview = new Png(dataStream);
|
||||||
|
|
||||||
|
newData.ModifiedDate = File.GetLastWriteTime(p.Name);
|
||||||
|
|
||||||
// Assign the new data atomically
|
// Assign the new data atomically
|
||||||
innerData = newData;
|
innerData = newData;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -64,6 +64,12 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
[TranslationReference]
|
[TranslationReference]
|
||||||
static readonly string DeleteAllMapsAccept = "delete-all-maps-accept";
|
static readonly string DeleteAllMapsAccept = "delete-all-maps-accept";
|
||||||
|
|
||||||
|
[TranslationReference]
|
||||||
|
static readonly string OrderMapsByPlayers = "order-maps-players";
|
||||||
|
|
||||||
|
[TranslationReference]
|
||||||
|
static readonly string OrderMapsByDate = "order-maps-date";
|
||||||
|
|
||||||
readonly Widget widget;
|
readonly Widget widget;
|
||||||
readonly DropDownButtonWidget gameModeDropdown;
|
readonly DropDownButtonWidget gameModeDropdown;
|
||||||
readonly ModData modData;
|
readonly ModData modData;
|
||||||
@@ -81,6 +87,10 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
string category;
|
string category;
|
||||||
string mapFilter;
|
string mapFilter;
|
||||||
|
|
||||||
|
Func<MapPreview, long> orderByFunc;
|
||||||
|
readonly string orderByPlayer;
|
||||||
|
readonly string orderByDate;
|
||||||
|
|
||||||
[ObjectCreator.UseCtor]
|
[ObjectCreator.UseCtor]
|
||||||
internal MapChooserLogic(Widget widget, ModData modData, string initialMap,
|
internal MapChooserLogic(Widget widget, ModData modData, string initialMap,
|
||||||
MapClassification initialTab, Action onExit, Action<string> onSelect, MapVisibility filter)
|
MapClassification initialTab, Action onExit, Action<string> onSelect, MapVisibility filter)
|
||||||
@@ -90,6 +100,8 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
this.onSelect = onSelect;
|
this.onSelect = onSelect;
|
||||||
|
|
||||||
allMaps = modData.Translation.GetString(AllMaps);
|
allMaps = modData.Translation.GetString(AllMaps);
|
||||||
|
orderByPlayer = modData.Translation.GetString(OrderMapsByPlayers);
|
||||||
|
orderByDate = modData.Translation.GetString(OrderMapsByDate);
|
||||||
|
|
||||||
var approving = new Action(() =>
|
var approving = new Action(() =>
|
||||||
{
|
{
|
||||||
@@ -109,6 +121,8 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
var itemTemplate = widget.Get<ScrollItemWidget>("MAP_TEMPLATE");
|
var itemTemplate = widget.Get<ScrollItemWidget>("MAP_TEMPLATE");
|
||||||
widget.RemoveChild(itemTemplate);
|
widget.RemoveChild(itemTemplate);
|
||||||
|
|
||||||
|
SetupOrderByDropdown(itemTemplate);
|
||||||
|
|
||||||
var mapFilterInput = widget.GetOrNull<TextFieldWidget>("MAPFILTER_INPUT");
|
var mapFilterInput = widget.GetOrNull<TextFieldWidget>("MAPFILTER_INPUT");
|
||||||
if (mapFilterInput != null)
|
if (mapFilterInput != null)
|
||||||
{
|
{
|
||||||
@@ -265,6 +279,38 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SetupOrderByDropdown(ScrollItemWidget itemTemplate)
|
||||||
|
{
|
||||||
|
var orderByDropdown = widget.GetOrNull<DropDownButtonWidget>("ORDERBY");
|
||||||
|
if (orderByDropdown == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var orderByDict = new Dictionary<string, Func<MapPreview, long>>()
|
||||||
|
{
|
||||||
|
{ orderByPlayer, m => m.PlayerCount },
|
||||||
|
{ orderByDate, m => -m.ModifiedDate.Ticks }
|
||||||
|
};
|
||||||
|
|
||||||
|
if (orderByFunc == null)
|
||||||
|
orderByFunc = orderByDict[orderByPlayer];
|
||||||
|
|
||||||
|
Func<string, ScrollItemWidget, ScrollItemWidget> setupItem = (o, template) =>
|
||||||
|
{
|
||||||
|
var item = ScrollItemWidget.Setup(template,
|
||||||
|
() => orderByFunc == orderByDict[o],
|
||||||
|
() => { orderByFunc = orderByDict[o]; EnumerateMaps(currentTab, itemTemplate); });
|
||||||
|
item.Get<LabelWidget>("LABEL").GetText = () => o;
|
||||||
|
|
||||||
|
return item;
|
||||||
|
};
|
||||||
|
|
||||||
|
orderByDropdown.OnClick = () =>
|
||||||
|
orderByDropdown.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 500, orderByDict.Keys, setupItem);
|
||||||
|
|
||||||
|
orderByDropdown.GetText = () =>
|
||||||
|
orderByDict.FirstOrDefault(m => m.Value == orderByFunc).Key;
|
||||||
|
}
|
||||||
|
|
||||||
void EnumerateMaps(MapClassification tab, ScrollItemWidget template)
|
void EnumerateMaps(MapClassification tab, ScrollItemWidget template)
|
||||||
{
|
{
|
||||||
if (!int.TryParse(mapFilter, out var playerCountFilter))
|
if (!int.TryParse(mapFilter, out var playerCountFilter))
|
||||||
@@ -276,7 +322,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
(m.Title != null && m.Title.IndexOf(mapFilter, StringComparison.OrdinalIgnoreCase) >= 0) ||
|
(m.Title != null && m.Title.IndexOf(mapFilter, StringComparison.OrdinalIgnoreCase) >= 0) ||
|
||||||
(m.Author != null && m.Author.IndexOf(mapFilter, StringComparison.OrdinalIgnoreCase) >= 0) ||
|
(m.Author != null && m.Author.IndexOf(mapFilter, StringComparison.OrdinalIgnoreCase) >= 0) ||
|
||||||
m.PlayerCount == playerCountFilter)
|
m.PlayerCount == playerCountFilter)
|
||||||
.OrderBy(m => m.PlayerCount)
|
.OrderBy(orderByFunc)
|
||||||
.ThenBy(m => m.Title);
|
.ThenBy(m => m.Title);
|
||||||
|
|
||||||
scrollpanels[tab].RemoveChildren();
|
scrollpanels[tab].RemoveChildren();
|
||||||
|
|||||||
@@ -14,35 +14,9 @@ Container@MAPCHOOSER_PANEL:
|
|||||||
Text: Select Map
|
Text: Select Map
|
||||||
Background@bg:
|
Background@bg:
|
||||||
Width: PARENT_RIGHT
|
Width: PARENT_RIGHT
|
||||||
Height: 540
|
Height: PARENT_BOTTOM
|
||||||
Background: panel-black
|
Background: panel-black
|
||||||
Children:
|
Children:
|
||||||
Label@FILTER_DESC:
|
|
||||||
X: PARENT_RIGHT - WIDTH - 401
|
|
||||||
Y: 16
|
|
||||||
Width: 60
|
|
||||||
Height: 25
|
|
||||||
Font: Bold
|
|
||||||
Align: Right
|
|
||||||
Text: Filter:
|
|
||||||
TextField@MAPFILTER_INPUT:
|
|
||||||
X: PARENT_RIGHT - WIDTH - 245
|
|
||||||
Y: 15
|
|
||||||
Width: 150
|
|
||||||
Height: 25
|
|
||||||
Label@FILTER_DESC_JOINER:
|
|
||||||
X: PARENT_RIGHT - WIDTH - 215
|
|
||||||
Y: 16
|
|
||||||
Width: 30
|
|
||||||
Height: 25
|
|
||||||
Font: Bold
|
|
||||||
Align: Center
|
|
||||||
Text: in
|
|
||||||
DropDownButton@GAMEMODE_FILTER:
|
|
||||||
X: PARENT_RIGHT - WIDTH - 15
|
|
||||||
Y: 15
|
|
||||||
Width: 200
|
|
||||||
Height: 25
|
|
||||||
Button@SYSTEM_MAPS_TAB_BUTTON:
|
Button@SYSTEM_MAPS_TAB_BUTTON:
|
||||||
X: 15
|
X: 15
|
||||||
Y: 15
|
Y: 15
|
||||||
@@ -55,21 +29,23 @@ Container@MAPCHOOSER_PANEL:
|
|||||||
Height: 31
|
Height: 31
|
||||||
Width: 135
|
Width: 135
|
||||||
Text: Custom Maps
|
Text: Custom Maps
|
||||||
Container@SYSTEM_MAPS_TAB:
|
Container@MAP_TAB_PANES:
|
||||||
|
Width: PARENT_RIGHT - 30
|
||||||
|
Height: PARENT_BOTTOM - 90
|
||||||
X: 15
|
X: 15
|
||||||
Y: 45
|
Y: 45
|
||||||
Width: PARENT_RIGHT - 30
|
Children:
|
||||||
Height: PARENT_BOTTOM - 60
|
Container@SYSTEM_MAPS_TAB:
|
||||||
|
Width: PARENT_RIGHT
|
||||||
|
Height: PARENT_BOTTOM
|
||||||
Children:
|
Children:
|
||||||
ScrollPanel@MAP_LIST:
|
ScrollPanel@MAP_LIST:
|
||||||
Width: PARENT_RIGHT
|
Width: PARENT_RIGHT
|
||||||
Height: PARENT_BOTTOM
|
Height: PARENT_BOTTOM
|
||||||
ItemSpacing: 1
|
ItemSpacing: 1
|
||||||
Container@USER_MAPS_TAB:
|
Container@USER_MAPS_TAB:
|
||||||
X: 15
|
Width: PARENT_RIGHT
|
||||||
Y: 45
|
Height: PARENT_BOTTOM
|
||||||
Width: PARENT_RIGHT - 30
|
|
||||||
Height: PARENT_BOTTOM - 60
|
|
||||||
Children:
|
Children:
|
||||||
ScrollPanel@MAP_LIST:
|
ScrollPanel@MAP_LIST:
|
||||||
Width: PARENT_RIGHT
|
Width: PARENT_RIGHT
|
||||||
@@ -120,35 +96,73 @@ Container@MAPCHOOSER_PANEL:
|
|||||||
Y: PARENT_BOTTOM - HEIGHT - 2
|
Y: PARENT_BOTTOM - HEIGHT - 2
|
||||||
Align: Center
|
Align: Center
|
||||||
Font: Tiny
|
Font: Tiny
|
||||||
|
Container@FILTER_ORDER_CONTROLS:
|
||||||
|
X: 15
|
||||||
|
Y: PARENT_BOTTOM - 40
|
||||||
|
Width: PARENT_RIGHT - 30
|
||||||
|
Height: PARENT_BOTTOM
|
||||||
|
Children:
|
||||||
|
Label@FILTER_DESC:
|
||||||
|
Width: 40
|
||||||
|
Height: 24
|
||||||
|
Font: Bold
|
||||||
|
Align: Right
|
||||||
|
Text: Filter:
|
||||||
|
TextField@MAPFILTER_INPUT:
|
||||||
|
X: 45
|
||||||
|
Width: 150
|
||||||
|
Height: 25
|
||||||
|
Label@FILTER_DESC_JOINER:
|
||||||
|
X: 195
|
||||||
|
Width: 30
|
||||||
|
Height: 24
|
||||||
|
Font: Bold
|
||||||
|
Align: Center
|
||||||
|
Text: in
|
||||||
|
DropDownButton@GAMEMODE_FILTER:
|
||||||
|
X: 225
|
||||||
|
Width: 200
|
||||||
|
Height: 25
|
||||||
|
Label@ORDERBY_LABEL:
|
||||||
|
X: PARENT_RIGHT - WIDTH - 200 - 5
|
||||||
|
Width: 100
|
||||||
|
Height: 24
|
||||||
|
Font: Bold
|
||||||
|
Align: Right
|
||||||
|
Text: Order by:
|
||||||
|
DropDownButton@ORDERBY:
|
||||||
|
X: PARENT_RIGHT - WIDTH
|
||||||
|
Width: 200
|
||||||
|
Height: 25
|
||||||
Button@BUTTON_CANCEL:
|
Button@BUTTON_CANCEL:
|
||||||
Key: escape
|
Key: escape
|
||||||
Y: 539
|
Y: PARENT_BOTTOM - 1
|
||||||
Width: 140
|
Width: 140
|
||||||
Height: 35
|
Height: 35
|
||||||
Text: Back
|
Text: Back
|
||||||
Button@RANDOMMAP_BUTTON:
|
Button@RANDOMMAP_BUTTON:
|
||||||
Key: space
|
Key: space
|
||||||
X: PARENT_RIGHT - 150 - WIDTH
|
X: PARENT_RIGHT - 150 - WIDTH
|
||||||
Y: 539
|
Y: PARENT_BOTTOM - 1
|
||||||
Width: 140
|
Width: 140
|
||||||
Height: 35
|
Height: 35
|
||||||
Text: Random
|
Text: Random
|
||||||
Button@DELETE_MAP_BUTTON:
|
Button@DELETE_MAP_BUTTON:
|
||||||
X: PARENT_RIGHT - 300 - WIDTH
|
X: PARENT_RIGHT - 300 - WIDTH
|
||||||
Y: 539
|
Y: PARENT_BOTTOM - 1
|
||||||
Width: 140
|
Width: 140
|
||||||
Height: 35
|
Height: 35
|
||||||
Text: Delete Map
|
Text: Delete Map
|
||||||
Button@DELETE_ALL_MAPS_BUTTON:
|
Button@DELETE_ALL_MAPS_BUTTON:
|
||||||
X: PARENT_RIGHT - 450 - WIDTH
|
X: PARENT_RIGHT - 450 - WIDTH
|
||||||
Y: 539
|
Y: PARENT_BOTTOM - 1
|
||||||
Width: 140
|
Width: 140
|
||||||
Height: 35
|
Height: 35
|
||||||
Text: Delete All Maps
|
Text: Delete All Maps
|
||||||
Button@BUTTON_OK:
|
Button@BUTTON_OK:
|
||||||
Key: return
|
Key: return
|
||||||
X: PARENT_RIGHT - WIDTH
|
X: PARENT_RIGHT - WIDTH
|
||||||
Y: 539
|
Y: PARENT_BOTTOM - 1
|
||||||
Width: 140
|
Width: 140
|
||||||
Height: 35
|
Height: 35
|
||||||
Text: Ok
|
Text: Ok
|
||||||
|
|||||||
@@ -26,26 +26,26 @@ Background@MAPCHOOSER_PANEL:
|
|||||||
Width: 140
|
Width: 140
|
||||||
Text: Custom Maps
|
Text: Custom Maps
|
||||||
Font: Bold
|
Font: Bold
|
||||||
|
Container@MAP_TAB_PANES:
|
||||||
|
Width: PARENT_RIGHT - 40
|
||||||
|
Height: 438
|
||||||
|
X: 20
|
||||||
|
Y: 77
|
||||||
|
Children:
|
||||||
Container@SYSTEM_MAPS_TAB:
|
Container@SYSTEM_MAPS_TAB:
|
||||||
X: 20
|
Width: PARENT_RIGHT
|
||||||
Y: 77
|
Height: PARENT_BOTTOM
|
||||||
Width: PARENT_RIGHT - 40
|
|
||||||
Height: 471
|
|
||||||
Children:
|
Children:
|
||||||
ScrollPanel@MAP_LIST:
|
ScrollPanel@MAP_LIST:
|
||||||
Width: PARENT_RIGHT
|
Width: PARENT_RIGHT
|
||||||
Height: PARENT_BOTTOM
|
Height: PARENT_BOTTOM
|
||||||
Children:
|
|
||||||
Container@USER_MAPS_TAB:
|
Container@USER_MAPS_TAB:
|
||||||
X: 20
|
Width: PARENT_RIGHT
|
||||||
Y: 77
|
Height: PARENT_BOTTOM
|
||||||
Width: PARENT_RIGHT - 40
|
|
||||||
Height: 471
|
|
||||||
Children:
|
Children:
|
||||||
ScrollPanel@MAP_LIST:
|
ScrollPanel@MAP_LIST:
|
||||||
Width: PARENT_RIGHT
|
Width: PARENT_RIGHT
|
||||||
Height: PARENT_BOTTOM
|
Height: PARENT_BOTTOM
|
||||||
Children:
|
|
||||||
ScrollItem@MAP_TEMPLATE:
|
ScrollItem@MAP_TEMPLATE:
|
||||||
Width: 208
|
Width: 208
|
||||||
Height: 266
|
Height: 266
|
||||||
@@ -91,30 +91,42 @@ Background@MAPCHOOSER_PANEL:
|
|||||||
Y: PARENT_BOTTOM - HEIGHT - 6
|
Y: PARENT_BOTTOM - HEIGHT - 6
|
||||||
Align: Center
|
Align: Center
|
||||||
Font: Tiny
|
Font: Tiny
|
||||||
|
Container@FILTER_ORDER_CONTROLS:
|
||||||
|
X: 20
|
||||||
|
Y: PARENT_BOTTOM - 80
|
||||||
|
Width: PARENT_RIGHT - 40
|
||||||
|
Height: PARENT_BOTTOM
|
||||||
|
Children:
|
||||||
Label@FILTER_DESC:
|
Label@FILTER_DESC:
|
||||||
X: PARENT_RIGHT - 467
|
Width: 40
|
||||||
Y: 50
|
|
||||||
Width: 60
|
|
||||||
Height: 24
|
Height: 24
|
||||||
Font: Bold
|
Font: Bold
|
||||||
Align: Right
|
Align: Right
|
||||||
Text: Filter:
|
Text: Filter:
|
||||||
TextField@MAPFILTER_INPUT:
|
TextField@MAPFILTER_INPUT:
|
||||||
X: PARENT_RIGHT - 401
|
X: 45
|
||||||
Y: 48
|
|
||||||
Width: 150
|
Width: 150
|
||||||
Height: 25
|
Height: 25
|
||||||
Label@FILTER_DESC_JOINER:
|
Label@FILTER_DESC_JOINER:
|
||||||
X: PARENT_RIGHT - 250
|
X: 195
|
||||||
Y: 48
|
|
||||||
Width: 30
|
Width: 30
|
||||||
Height: 24
|
Height: 24
|
||||||
Font: Bold
|
Font: Bold
|
||||||
Align: Center
|
Align: Center
|
||||||
Text: in
|
Text: in
|
||||||
DropDownButton@GAMEMODE_FILTER:
|
DropDownButton@GAMEMODE_FILTER:
|
||||||
X: PARENT_RIGHT - 220
|
X: 225
|
||||||
Y: 48
|
Width: 200
|
||||||
|
Height: 25
|
||||||
|
Label@ORDERBY_LABEL:
|
||||||
|
X: PARENT_RIGHT - WIDTH - 200 - 5
|
||||||
|
Width: 100
|
||||||
|
Height: 24
|
||||||
|
Font: Bold
|
||||||
|
Align: Right
|
||||||
|
Text: Order by:
|
||||||
|
DropDownButton@ORDERBY:
|
||||||
|
X: PARENT_RIGHT - WIDTH
|
||||||
Width: 200
|
Width: 200
|
||||||
Height: 25
|
Height: 25
|
||||||
Button@RANDOMMAP_BUTTON:
|
Button@RANDOMMAP_BUTTON:
|
||||||
|
|||||||
@@ -449,6 +449,9 @@ delete-all-maps-title = Delete maps
|
|||||||
delete-all-maps-prompt = Delete all maps on this page?
|
delete-all-maps-prompt = Delete all maps on this page?
|
||||||
delete-all-maps-accept = Delete
|
delete-all-maps-accept = Delete
|
||||||
|
|
||||||
|
order-maps-players = Players
|
||||||
|
order-maps-date = Map Date
|
||||||
|
|
||||||
## MissionBrowserLogic
|
## MissionBrowserLogic
|
||||||
no-video-title = Video not installed
|
no-video-title = Video not installed
|
||||||
no-video-prompt = The game videos can be installed from the
|
no-video-prompt = The game videos can be installed from the
|
||||||
|
|||||||
Reference in New Issue
Block a user