mirror of
https://github.com/badvision/lawless-legends.git
synced 2025-01-12 12:30:07 +00:00
Maps are now sorted alphabetically
This commit is contained in:
parent
55023ceb79
commit
31c14d8d4c
@ -4,10 +4,10 @@ import java.util.List;
|
||||
import org.badvision.outlaweditor.Application;
|
||||
import org.badvision.outlaweditor.data.xml.Field;
|
||||
import org.badvision.outlaweditor.data.xml.Global;
|
||||
import org.badvision.outlaweditor.data.xml.Map;
|
||||
import org.badvision.outlaweditor.data.xml.NamedEntity;
|
||||
import org.badvision.outlaweditor.data.xml.Scope;
|
||||
import org.badvision.outlaweditor.data.xml.Script;
|
||||
import org.badvision.outlaweditor.data.xml.Scripts;
|
||||
|
||||
public class DataUtilities {
|
||||
|
||||
@ -17,6 +17,23 @@ public class DataUtilities {
|
||||
}
|
||||
}
|
||||
|
||||
public static void sortMaps(List<? extends Map> entities) {
|
||||
if (entities == null) {
|
||||
return;
|
||||
}
|
||||
entities.sort((a, b) -> {
|
||||
String nameA = a == null ? "" : nullSafe(a.getName());
|
||||
String nameB = b == null ? "" : nullSafe(b.getName());
|
||||
if (nameA.equalsIgnoreCase("init")) {
|
||||
return -1;
|
||||
}
|
||||
if (nameB.equalsIgnoreCase("init")) {
|
||||
return 1;
|
||||
}
|
||||
return nameA.compareTo(nameB);
|
||||
});
|
||||
}
|
||||
|
||||
public static void sortNamedEntities(List<? extends NamedEntity> entities) {
|
||||
if (entities == null) {
|
||||
return;
|
||||
|
@ -28,7 +28,6 @@ import static org.badvision.outlaweditor.data.PropertyHelper.stringProp;
|
||||
import org.badvision.outlaweditor.data.TileUtils;
|
||||
import org.badvision.outlaweditor.data.xml.Map;
|
||||
import org.badvision.outlaweditor.data.xml.Script;
|
||||
import org.badvision.outlaweditor.data.xml.Scripts;
|
||||
import org.badvision.outlaweditor.data.xml.Tile;
|
||||
import org.badvision.outlaweditor.ui.EntitySelectorCell;
|
||||
import org.badvision.outlaweditor.ui.MapEditorTabController;
|
||||
@ -206,7 +205,7 @@ public class MapEditorTabControllerImpl extends MapEditorTabController {
|
||||
redrawMapScripts();
|
||||
},
|
||||
null);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -282,7 +281,7 @@ public class MapEditorTabControllerImpl extends MapEditorTabController {
|
||||
} else {
|
||||
if (m.getScripts() != null) {
|
||||
DataUtilities.sortNamedEntities(m.getScripts().getScript());
|
||||
};
|
||||
}
|
||||
if (m.getHeight() == null) {
|
||||
m.setHeight(512);
|
||||
}
|
||||
@ -321,6 +320,7 @@ public class MapEditorTabControllerImpl extends MapEditorTabController {
|
||||
@Override
|
||||
public void rebuildMapSelectors() {
|
||||
mapSelect.getItems().clear();
|
||||
DataUtilities.sortMaps(Application.gameData.getMap());
|
||||
mapSelect.getItems().addAll(Application.gameData.getMap());
|
||||
mapSelect.getSelectionModel().select(getCurrentMap());
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user