@@ -94,7 +94,12 @@ public class Maps{
|
||||
|
||||
/** Returns a list of only default maps. */
|
||||
public Seq<Map> defaultMaps(){
|
||||
return maps.select(m -> !m.custom);
|
||||
return maps.select(m -> !m.custom && m.mod == null);
|
||||
}
|
||||
|
||||
/** Returns a list of only modded maps. */
|
||||
public Seq<Map> moddedMaps(){
|
||||
return maps.select(m -> m.mod != null);
|
||||
}
|
||||
|
||||
public Map byName(String name){
|
||||
|
||||
@@ -2,6 +2,7 @@ package mindustry.ui.dialogs;
|
||||
|
||||
import arc.*;
|
||||
import arc.graphics.*;
|
||||
import arc.input.KeyCode;
|
||||
import arc.scene.style.*;
|
||||
import arc.scene.ui.*;
|
||||
import arc.scene.ui.layout.*;
|
||||
@@ -27,8 +28,12 @@ public abstract class MapListDialog extends BaseDialog{
|
||||
private boolean
|
||||
showBuiltIn = Core.settings.getBool("editorshowbuiltinmaps", true),
|
||||
showCustom = Core.settings.getBool("editorshowcustommaps", true),
|
||||
showModded = Core.settings.getBool("editorshowmoddedmaps", true),
|
||||
searchAuthor = Core.settings.getBool("editorsearchauthor", false),
|
||||
searchDescription = Core.settings.getBool("editorsearchdescription", false),
|
||||
searchModname = Core.settings.getBool("editorsearchmodname", false),
|
||||
prioritizeModded = Core.settings.getBool("editorprioritizemodded", false),
|
||||
prioritizeCustom = Core.settings.getBool("editorprioritizecustom", false),
|
||||
displayType;
|
||||
|
||||
public MapListDialog(String title, boolean displayType){
|
||||
@@ -88,7 +93,7 @@ public abstract class MapListDialog extends BaseDialog{
|
||||
|
||||
cont.add(search).growX();
|
||||
cont.row();
|
||||
cont.add(pane).padLeft(28f).uniformX().growY();
|
||||
cont.add(pane).padLeft(28f).uniformX().grow().padBottom(64f);
|
||||
}
|
||||
|
||||
void rebuildMaps(){
|
||||
@@ -102,11 +107,27 @@ public abstract class MapListDialog extends BaseDialog{
|
||||
|
||||
int i = 0;
|
||||
|
||||
Seq<Map> mapList = showCustom ?
|
||||
showBuiltIn ? maps.all() : maps.customMaps() :
|
||||
showBuiltIn ? maps.defaultMaps() : null;
|
||||
Seq<Map> mapList = new Seq<>();
|
||||
|
||||
if(showCustom) mapList.addAll(maps.customMaps());
|
||||
if(showBuiltIn) mapList.addAll(maps.defaultMaps());
|
||||
if(showModded) mapList.addAll(maps.moddedMaps());
|
||||
|
||||
mapList = mapList.distinct();
|
||||
|
||||
if(mapList != null){
|
||||
if(prioritizeModded){
|
||||
Seq<Map> ordered = new Seq<>();
|
||||
ordered.addAll(mapList.select(m -> m.mod != null)).sortComparing(m -> m.mod.meta.displayName);
|
||||
ordered.addAll(mapList.select(m -> m.mod == null));
|
||||
mapList = ordered;
|
||||
}
|
||||
if(prioritizeCustom){
|
||||
Seq<Map> ordered = new Seq<>();
|
||||
ordered.addAll(mapList.select(m -> m.custom)).sortComparing(m -> m.plainName());
|
||||
ordered.addAll(mapList.select(m -> !m.custom));
|
||||
mapList = ordered;
|
||||
}
|
||||
for(Map map : mapList){
|
||||
|
||||
boolean invalid = false;
|
||||
@@ -116,7 +137,8 @@ public abstract class MapListDialog extends BaseDialog{
|
||||
if(invalid || (searchString != null
|
||||
&& !map.plainName().toLowerCase().contains(searchString)
|
||||
&& (!searchAuthor || !map.plainAuthor().toLowerCase().contains(searchString))
|
||||
&& (!searchDescription || !map.plainDescription().toLowerCase().contains(searchString)))){
|
||||
&& (!searchDescription || !map.plainDescription().toLowerCase().contains(searchString))
|
||||
&& (!searchModname || !(map.mod == null ? "" : Strings.stripColors(map.mod.meta.displayName).toLowerCase()).contains(searchString)))){
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -169,29 +191,63 @@ public abstract class MapListDialog extends BaseDialog{
|
||||
activeDialog = new BaseDialog("@editor.filters");
|
||||
activeDialog.addCloseButton();
|
||||
activeDialog.cont.table(menu -> {
|
||||
menu.add("@editor.filters.mode").width(150f).left();
|
||||
menu.table(t -> {
|
||||
for(Gamemode mode : Gamemode.all){
|
||||
TextureRegionDrawable icon = Vars.ui.getIcon("mode" + Strings.capitalize(mode.name()));
|
||||
if(Core.atlas.isFound(icon.getRegion())){
|
||||
t.button(icon, Styles.emptyTogglei, () -> {
|
||||
if(modes.contains(mode)){
|
||||
modes.remove(mode);
|
||||
}else{
|
||||
modes.add(mode);
|
||||
menu.table(tab -> {
|
||||
// Gamemodes
|
||||
tab.table(t -> {
|
||||
t.add("@editor.filters.mode").padBottom(6f).row();
|
||||
t.table(Tex.button, left -> {
|
||||
for(Gamemode mode : Gamemode.all){
|
||||
TextureRegionDrawable icon = Vars.ui.getIcon("mode" + Strings.capitalize(mode.name()));
|
||||
if(Core.atlas.isFound(icon.getRegion())){
|
||||
left.button(icon, Styles.emptyTogglei, () -> {
|
||||
if(modes.contains(mode)){
|
||||
modes.remove(mode);
|
||||
}else{
|
||||
modes.add(mode);
|
||||
}
|
||||
rebuildMaps();
|
||||
}).left().size(60f).checked(modes.contains(mode)).tooltip("@mode." + mode.name() + ".name");
|
||||
}
|
||||
}
|
||||
});
|
||||
}).pad(5f);
|
||||
tab.add().width(60f);
|
||||
// Priorities
|
||||
tab.table(t -> {
|
||||
t.add("@editor.filters.priorities").padBottom(6f).row();
|
||||
t.table(Tex.button, right ->{
|
||||
right.button(ui.getIcon("players"), Styles.emptyTogglei, () -> {
|
||||
prioritizeCustom = !prioritizeCustom;
|
||||
if(prioritizeModded){
|
||||
prioritizeModded = false;
|
||||
Core.settings.put("editorprioritizemodded", false);
|
||||
}
|
||||
Core.settings.put("editorprioritizecustom", prioritizeCustom);
|
||||
rebuildMaps();
|
||||
}).size(60f).checked(modes.contains(mode)).tooltip("@mode." + mode.name() + ".name");
|
||||
}
|
||||
}
|
||||
}).size(60f).checked(b-> showCustom && prioritizeCustom).tooltip("@editor.filters.prioritizecustom").disabled(b -> !showCustom);
|
||||
right.button(ui.getIcon("hammer"), Styles.emptyTogglei, () -> {
|
||||
prioritizeModded = !prioritizeModded;
|
||||
if(prioritizeCustom){
|
||||
prioritizeCustom = false;
|
||||
Core.settings.put("editorprioritizecustom", false);
|
||||
}
|
||||
Core.settings.put("editorprioritizemodded", prioritizeModded);
|
||||
rebuildMaps();
|
||||
}).size(60f).checked(b-> showModded && prioritizeModded).tooltip("@editor.filters.prioritizemod").disabled(b -> !showModded);
|
||||
});
|
||||
}).expandX().pad(5f);
|
||||
}).padBottom(10f);
|
||||
menu.row();
|
||||
|
||||
menu.add("@editor.filters.type").width(150f).left();
|
||||
menu.add("@editor.filters.type").width(120f).left().row();
|
||||
menu.table(Tex.button, t -> {
|
||||
t.button("@custom", Styles.flatTogglet, () -> {
|
||||
showCustom = !showCustom;
|
||||
Core.settings.put("editorshowcustommaps", showCustom);
|
||||
if(!showCustom){
|
||||
prioritizeCustom = false;
|
||||
Core.settings.put("editorprioritizecustom", false);
|
||||
}
|
||||
rebuildMaps();
|
||||
}).size(150f, 60f).checked(showCustom);
|
||||
t.button("@builtin", Styles.flatTogglet, () -> {
|
||||
@@ -199,10 +255,18 @@ public abstract class MapListDialog extends BaseDialog{
|
||||
Core.settings.put("editorshowbuiltinmaps", showBuiltIn);
|
||||
rebuildMaps();
|
||||
}).size(150f, 60f).checked(showBuiltIn);
|
||||
t.button("@modded", Styles.flatTogglet, () -> {
|
||||
showModded = !showModded;
|
||||
Core.settings.put("editorshowmoddedmaps", showModded);
|
||||
if(!showModded){
|
||||
prioritizeModded = false;
|
||||
Core.settings.put("editorprioritizemodded", false);
|
||||
}
|
||||
rebuildMaps();
|
||||
}).size(150f, 60f).checked(showModded);
|
||||
}).padBottom(10f);
|
||||
menu.row();
|
||||
|
||||
menu.add("@editor.filters.search").width(150f).left();
|
||||
menu.add("@editor.filters.search").width(120f).left().row();
|
||||
menu.table(Tex.button, t -> {
|
||||
t.button("@editor.filters.author", Styles.flatTogglet, () -> {
|
||||
searchAuthor = !searchAuthor;
|
||||
@@ -214,6 +278,11 @@ public abstract class MapListDialog extends BaseDialog{
|
||||
Core.settings.put("editorsearchdescription", searchDescription);
|
||||
rebuildMaps();
|
||||
}).size(150f, 60f).checked(searchDescription);
|
||||
t.button("@editor.filters.modname", Styles.flatTogglet, () -> {
|
||||
searchModname = !searchModname;
|
||||
Core.settings.put("editorsearchmodname", searchModname);
|
||||
rebuildMaps();
|
||||
}).size(150f, 60f).checked(searchModname);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user