Add sort-by-recently-played option to the map list (#12638)

* Add sort-by-recently-played option to the map list

The existing "recent" sort orders by the map file's last-modified
time, which only reflects edits - built-in maps never touch their
file, so it's meaningless for them, and for custom maps it tracks
last edited, not last played.

Track an actual last-played timestamp per map, the same way
high scores are already tracked (Core.settings, keyed by filename),
updated whenever a map finishes loading successfully outside of
playtesting. Add it as a fifth MapPriority option alongside the
existing four.

Resolves Anuken/Mindustry-Suggestions#5115

* Use eyeSmall icon per review feedback
This commit is contained in:
Александр Голомшток
2026-09-12 10:53:42 -04:00
committed by GitHub
parent 1ee9684d96
commit 3be43b1a54
4 changed files with 15 additions and 2 deletions
+1
View File
@@ -534,6 +534,7 @@ editor.filters.prioritize.name = Prioritize: Name
editor.filters.prioritize.custom = Prioritize: Custom
editor.filters.prioritize.builtin = Prioritize: Built-In
editor.filters.prioritize.recent = Prioritize: Recently Modified
editor.filters.prioritize.played = Prioritize: Recently Played
editor.filters.planetselect = Planet Selection
editor.shiftx = Shift X
editor.shifty = Shift Y
+3
View File
@@ -440,6 +440,9 @@ public class Control implements ApplicationListener, Loadable{
if(settings.getBool("savecreate") && !world.isInvalidMap() && !playtest){
control.saves.addSave(map.name() + " " + new SimpleDateFormat("MMM dd h:mm", Locale.getDefault()).format(new Date()));
}
if(!world.isInvalidMap() && !playtest){
map.setLastPlayed();
}
Events.fire(Trigger.newGame);
//booted out of map, resume editing
+8
View File
@@ -83,6 +83,14 @@ public class Map implements Comparable<Map>, Publishable{
Core.settings.put("hiscore" + file.nameWithoutExtension() + tags.get("steamid", ""), score);
}
public long getLastPlayed(){
return Core.settings.getLong("lastplayed" + file.nameWithoutExtension() + tags.get("steamid", ""), 0);
}
public void setLastPlayed(){
Core.settings.put("lastplayed" + file.nameWithoutExtension() + tags.get("steamid", ""), Time.millis());
}
/** Returns the result of applying this map's rules to the specified gamemode.*/
public Rules applyRules(Gamemode mode){
//mode specific defaults have been applied
@@ -44,7 +44,8 @@ public abstract class MapListDialog extends BaseDialog{
name(Structs.comparing(Map::name)),
custom(Structs.comps(Structs.comparingBool(m -> !m.custom), Structs.comparingLong(m -> -m.file.lastModified()))),
builtin(Structs.comps(Structs.comparingBool(m -> m.custom), Structs.comparingLong(m -> -m.file.lastModified()))),
recent(Structs.comps(Structs.comparingLong(m -> -m.file.lastModified()), Structs.comparing(Map::name)));
recent(Structs.comps(Structs.comparingLong(m -> -m.file.lastModified()), Structs.comparing(Map::name))),
played(Structs.comps(Structs.comparingLong(m -> -m.getLastPlayed()), Structs.comparing(Map::name)));
final Comparator<Map> comparator;
@@ -254,7 +255,7 @@ public abstract class MapListDialog extends BaseDialog{
tab.table(t -> {
t.add("@editor.filters.priorities").padBottom(6f).row();
t.table(Tex.button, right -> {
TextureRegionDrawable[] icons = {Icon.fileText, Icon.players, Icon.hammer, Icon.play};
TextureRegionDrawable[] icons = {Icon.fileText, Icon.players, Icon.hammer, Icon.play, Icon.eyeSmall};
for(int i = 0; i < MapPriority.all.length; i++){
var prio = MapPriority.all[i];