Sort scripts alphabetically now

This commit is contained in:
Brendan Robert 2015-05-20 23:15:31 -05:00
parent 7541cf4a52
commit 71f20dcf1b
2 changed files with 13 additions and 1 deletions

View File

@ -28,7 +28,6 @@ import javafx.scene.input.ScrollEvent;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.Pane;
import javafx.scene.paint.Color;
import javafx.scene.shape.FillRule;
import javafx.scene.shape.Rectangle;
import javafx.stage.Stage;
import static org.badvision.outlaweditor.Application.currentPlatform;

View File

@ -225,6 +225,7 @@ public class MapEditorTabControllerImpl extends MapEditorTabController {
mapWrapAround.setDisable(true);
setCurrentEditor(null);
} else {
sortScripts(m);
if (m.getHeight() == null) {
m.setHeight(512);
}
@ -367,6 +368,7 @@ public class MapEditorTabControllerImpl extends MapEditorTabController {
mapScriptsList.getItems().clear();
} else {
if (mapScriptsList.getItems() != null && getCurrentMap().getScripts() != null) {
sortScripts(getCurrentMap());
mapScriptsList.getItems().setAll(getCurrentMap().getScripts().getScript());
} else {
mapScriptsList.getItems().clear();
@ -395,4 +397,15 @@ public class MapEditorTabControllerImpl extends MapEditorTabController {
visibilityIcon.setImage(VISIBLE_IMAGE);
}
}
private void sortScripts(Map m) {
m.getScripts().getScript().sort((a,b)-> {
if (a.getName().equalsIgnoreCase("init")) {
return -1;
} else if (b.getName().equalsIgnoreCase("init")) {
return 1;
}
return a.getName().compareTo(b.getName());
});
}
}