mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 12:18:00 +00:00
- Sort puzzles alphabetically in the puzzle selection list box.
This commit is contained in:
@@ -21,6 +21,8 @@ import javax.swing.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
public enum CSubmenuPuzzleSolve implements ICDoc, IMenuProvider {
|
||||
@@ -50,6 +52,8 @@ public enum CSubmenuPuzzleSolve implements ICDoc, IMenuProvider {
|
||||
|
||||
private void updateData() {
|
||||
final ArrayList<Puzzle> puzzles = PuzzleIO.loadPuzzles();
|
||||
Collections.sort(puzzles);
|
||||
|
||||
for(Puzzle p : puzzles) {
|
||||
view.getModel().addElement(p);
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ import forge.model.FModel;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class Puzzle extends GameState implements InventoryItem {
|
||||
public class Puzzle extends GameState implements InventoryItem, Comparable {
|
||||
String name;
|
||||
String goal;
|
||||
String url;
|
||||
@@ -104,4 +104,12 @@ public class Puzzle extends GameState implements InventoryItem {
|
||||
}
|
||||
|
||||
public String toString() { return name; }
|
||||
|
||||
public int compareTo(Object pzl) throws ClassCastException {
|
||||
if (!(pzl instanceof Puzzle)) {
|
||||
throw new ClassCastException("Tried to compare a Puzzle object to a non-Puzzle object.");
|
||||
}
|
||||
|
||||
return getName().compareTo(((Puzzle)pzl).getName());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user