use of com.github.jakz.romlib.data.game.GameStatus in project rom-manager by Jakz.
the class ViewMenu method rebuild.
void rebuild(GameSet set, GameListData.Mode mode) {
if (set != null) {
// TODO: mind that there's no check for overlap
final int firstStroke = KeyEvent.VK_F1;
final GameStatus[] statuses = GameStatus.values();
for (int i = 0; i < filterByStatus.length; ++i) {
filterByStatus[i] = new JCheckBoxMenuItem("Show " + statuses[i].name.toLowerCase(), true);
filterByStatus[i].setAccelerator(KeyStroke.getKeyStroke(firstStroke + i, 0));
filterByStatus[i].addActionListener(listener);
add(filterByStatus[i]);
}
if (set.hasFeature(Feature.CLONES)) {
JMenu modeMenu = new JMenu("Mode");
viewModes = new JRadioButtonMenuItem[2];
viewModes[0] = new JRadioButtonMenuItem("Games");
viewModes[1] = new JRadioButtonMenuItem("Clones");
viewModesRadioGroup = new ButtonGroup();
viewModesRadioGroup.add(viewModes[0]);
viewModesRadioGroup.add(viewModes[1]);
(mode == GameListData.Mode.CLONES ? viewModes[1] : viewModes[0]).setSelected(true);
modeMenu.add(viewModes[0]);
modeMenu.add(viewModes[1]);
ActionListener switchModeListener = e -> {
GameListData.Mode m = e.getSource() == viewModes[0] ? GameListData.Mode.GAMES : GameListData.Mode.CLONES;
mediator.switchGameListMode(m);
};
viewModes[0].addActionListener(switchModeListener);
viewModes[1].addActionListener(switchModeListener);
add(modeMenu);
}
addSeparator();
sortCriteriaRadioGroup = new ButtonGroup();
sortCriteria = new JRadioButtonMenuItem[sortAttributes.length + 1];
JMenu sortMenu = new JMenu(Text.MENU_VIEW_SORT_BY.text());
sortCriteria[0] = new JRadioButtonMenuItem("None");
for (int i = 0; i < sortAttributes.length; ++i) sortCriteria[i + 1] = new JRadioButtonMenuItem(sortAttributes[i].getCaption());
for (JRadioButtonMenuItem menuItem : sortCriteria) {
menuItem.addActionListener(listener);
sortCriteriaRadioGroup.add(menuItem);
sortMenu.add(menuItem);
}
sortCriteria[0].setSelected(true);
sortCriteria[3].setEnabled(set.doesSupportAttribute(GameAttribute.NUMBER));
reverseSortOrder = new JCheckBoxMenuItem(Text.MENU_VIEW_REVERSE_ORDER.text());
reverseSortOrder.addActionListener(listener);
add(sortMenu);
add(reverseSortOrder);
}
}
use of com.github.jakz.romlib.data.game.GameStatus in project rom-manager by Jakz.
the class ViewMenu method rebuild.
void rebuild(GameSet set, GameListData.Mode mode, boolean isTreeMode) {
if (set != null) {
// TODO: mind that there's no check for overlap
final int firstStroke = KeyEvent.VK_F1;
final GameStatus[] statuses = GameStatus.values();
for (int i = 0; i < filterByStatus.length; ++i) {
filterByStatus[i] = new JCheckBoxMenuItem("Show " + statuses[i].name.toLowerCase(), true);
filterByStatus[i].setAccelerator(KeyStroke.getKeyStroke(firstStroke + i, 0));
filterByStatus[i].addActionListener(listener);
add(filterByStatus[i]);
}
if (set.hasFeature(Feature.CLONES)) {
JMenu modeMenu = new JMenu("Mode");
viewModes = new JRadioButtonMenuItem[3];
viewModes[0] = new JRadioButtonMenuItem("Games");
viewModes[1] = new JRadioButtonMenuItem("Clones");
viewModes[2] = new JRadioButtonMenuItem("Clones Tree");
viewModesRadioGroup = new ButtonGroup();
viewModesRadioGroup.add(viewModes[0]);
viewModesRadioGroup.add(viewModes[1]);
viewModesRadioGroup.add(viewModes[2]);
if (isTreeMode)
viewModes[2].setSelected(true);
else if (mode == GameListData.Mode.CLONES)
viewModes[1].setSelected(true);
else
viewModes[0].setSelected(true);
;
modeMenu.add(viewModes[0]);
modeMenu.add(viewModes[1]);
modeMenu.add(viewModes[2]);
ActionListener switchModeListener = e -> {
GameListData.Mode m = e.getSource() == viewModes[0] ? GameListData.Mode.GAMES : GameListData.Mode.CLONES;
boolean treeMode = e.getSource() == viewModes[2];
mediator.switchGameListMode(m, treeMode);
};
viewModes[0].addActionListener(switchModeListener);
viewModes[1].addActionListener(switchModeListener);
viewModes[2].addActionListener(switchModeListener);
add(modeMenu);
}
addSeparator();
sortCriteriaRadioGroup = new ButtonGroup();
sortCriteria = new JRadioButtonMenuItem[sortAttributes.length + 1];
JMenu sortMenu = new JMenu(Text.MENU_VIEW_SORT_BY.text());
sortCriteria[0] = new JRadioButtonMenuItem("None");
for (int i = 0; i < sortAttributes.length; ++i) sortCriteria[i + 1] = new JRadioButtonMenuItem(sortAttributes[i].getCaption());
for (JRadioButtonMenuItem menuItem : sortCriteria) {
menuItem.addActionListener(listener);
sortCriteriaRadioGroup.add(menuItem);
sortMenu.add(menuItem);
}
sortCriteria[0].setSelected(true);
sortCriteria[3].setEnabled(set.doesSupportAttribute(GameAttribute.NUMBER));
reverseSortOrder = new JCheckBoxMenuItem(Text.MENU_VIEW_REVERSE_ORDER.text());
reverseSortOrder.addActionListener(listener);
add(sortMenu);
add(reverseSortOrder);
}
}
use of com.github.jakz.romlib.data.game.GameStatus in project rom-manager by Jakz.
the class GameCellRenderer method decorate.
private void decorate(Drawable entry, boolean isSelected, Color bg) {
decorateLabel(mainLabel, entry);
GameStatus status = entry.getDrawableStatus();
if (entry.getDrawableFavourite())
rightIcon.setIcon(Icon.FAVORITE.getIcon());
else
rightIcon.setIcon(null);
if (isSelected) {
mainLabel.setForeground(Color.WHITE);
setBackground(status.color);
} else {
setBackground(bg);
mainLabel.setForeground(status.color);
}
}
Aggregations