Skip to content

Commit

Permalink
code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
kuronekochomusuke committed Nov 10, 2024
1 parent 20d5296 commit 71c8c65
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,13 @@ private JPanel createFilter() {
JPanel filterPanel = new JPanel();
filterPanel.setLayout(new BoxLayout(filterPanel, BoxLayout.PAGE_AXIS));

filterPanel.add(createFilterTags());
filterPanel.add(createFilterPaths());

return filterPanel;
}

private JPanel createFilterTags() {
List<String> tags = Arrays.stream(BoardsTagger.Tags.values()).map(BoardsTagger.Tags::getName).distinct().sorted().toList();
DefaultListModel<String> tagsModel = new DefaultListModel<>();
tagsModel.addAll(tags);
Expand All @@ -111,8 +118,11 @@ public void valueChanged(ListSelectionEvent e) {
JPanel boardTagsPanel = new JPanel(new BorderLayout());
boardTagsPanel.add(new JLabel("Board Tags"), BorderLayout.NORTH);
boardTagsPanel.add(new JScrollPane(listBoardTags), BorderLayout.CENTER);
filterPanel.add(boardTagsPanel);

return boardTagsPanel;
}

private JPanel createFilterPaths() {
List<String> paths = bc.getBoardPaths().values().stream().toList();
paths = paths.stream().map(p -> p.substring(0, p.lastIndexOf("\\") + 1 )).distinct().sorted().toList();
DefaultListModel<String> pathsModel = new DefaultListModel<>();
Expand All @@ -129,9 +139,8 @@ public void valueChanged(ListSelectionEvent e) {
JPanel boardPathsPanel = new JPanel(new BorderLayout());
boardPathsPanel.add(new JLabel("Board Paths"), BorderLayout.NORTH);
boardPathsPanel.add(new JScrollPane(listBoardPaths), BorderLayout.CENTER);
filterPanel.add(boardPathsPanel);

return filterPanel;
return boardPathsPanel;
}

private JPanel createList() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
import java.util.List;

/**
* A table model for the advanced search weapon tab's equipment list
* A table model for the advanced map search
*/
class BoardTableModel extends AbstractTableModel {
private static final int COL_NAME = 0;
Expand Down
20 changes: 10 additions & 10 deletions megamek/src/megamek/utilities/BoardClassifier.java
Original file line number Diff line number Diff line change
Expand Up @@ -152,18 +152,18 @@ private void scanForBoardsInDir(final File boardDir, final String basePath) {

getBoardsByHeight().get(dimension.height()).add(filePath.getPath());
getBoardsByWidth().get(dimension.width()).add(filePath.getPath());
}

for (String tagString : Board.getTags(filePath)) {
Tags tag = Tags.parse(tagString);
getBoardsByTag().putIfAbsent(tag, new ArrayList<>());
getBoardsByTag().get(tag).add(filePath.getPath());
}
for (String tagString : Board.getTags(filePath)) {
Tags tag = Tags.parse(tagString);
getBoardsByTag().putIfAbsent(tag, new ArrayList<>());
getBoardsByTag().get(tag).add(filePath.getPath());
}

getBoardPaths().put(filePath.getPath(), partialBoardPath);
getBoardTags().put(filePath.getPath(), Board.getTags(filePath).toString());
getBoardWidth().put(filePath.getPath(), dimension.width());
getBoardHeigth().put(filePath.getPath(), dimension.height());
getBoardPaths().put(filePath.getPath(), partialBoardPath);
getBoardTags().put(filePath.getPath(), Board.getTags(filePath).toString());
getBoardWidth().put(filePath.getPath(), dimension.width());
getBoardHeigth().put(filePath.getPath(), dimension.height());
}
}
}
}
Expand Down

0 comments on commit 71c8c65

Please sign in to comment.