Search in sources :

Example 1 with GameStatus

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);
    }
}
Also used : GameStatus(com.github.jakz.romlib.data.game.GameStatus) Arrays(java.util.Arrays) ActionListener(java.awt.event.ActionListener) BiFunction(java.util.function.BiFunction) GameAttribute(com.github.jakz.romlib.data.game.attributes.GameAttribute) Game(com.github.jakz.romlib.data.game.Game) Attribute(com.github.jakz.romlib.data.game.attributes.Attribute) JCheckBoxMenuItem(javax.swing.JCheckBoxMenuItem) GameSet(com.github.jakz.romlib.data.set.GameSet) StreamUtil(com.pixbits.lib.functional.StreamUtil) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Text(jack.rm.i18n.Text) ButtonModel(javax.swing.ButtonModel) GameListData(jack.rm.gui.gamelist.GameListData) Feature(com.github.jakz.romlib.data.set.Feature) KeyStroke(javax.swing.KeyStroke) ButtonGroup(javax.swing.ButtonGroup) Predicate(java.util.function.Predicate) JMenu(javax.swing.JMenu) GameStatus(com.github.jakz.romlib.data.game.GameStatus) KeyEvent(java.awt.event.KeyEvent) List(java.util.List) Drawable(com.github.jakz.romlib.data.game.Drawable) JRadioButtonMenuItem(javax.swing.JRadioButtonMenuItem) Comparator(java.util.Comparator) Pair(com.pixbits.lib.lang.Pair) ActionListener(java.awt.event.ActionListener) ButtonGroup(javax.swing.ButtonGroup) JRadioButtonMenuItem(javax.swing.JRadioButtonMenuItem) JCheckBoxMenuItem(javax.swing.JCheckBoxMenuItem) JMenu(javax.swing.JMenu)

Example 2 with GameStatus

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);
    }
}
Also used : GameStatus(com.github.jakz.romlib.data.game.GameStatus) Arrays(java.util.Arrays) ActionListener(java.awt.event.ActionListener) BiFunction(java.util.function.BiFunction) GameAttribute(com.github.jakz.romlib.data.game.attributes.GameAttribute) Game(com.github.jakz.romlib.data.game.Game) Attribute(com.github.jakz.romlib.data.game.attributes.Attribute) JCheckBoxMenuItem(javax.swing.JCheckBoxMenuItem) GameSet(com.github.jakz.romlib.data.set.GameSet) StreamUtil(com.pixbits.lib.functional.StreamUtil) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Text(jack.rm.i18n.Text) ButtonModel(javax.swing.ButtonModel) GameListData(jack.rm.gui.gamelist.GameListData) Feature(com.github.jakz.romlib.data.set.Feature) KeyStroke(javax.swing.KeyStroke) ButtonGroup(javax.swing.ButtonGroup) Predicate(java.util.function.Predicate) JMenu(javax.swing.JMenu) GameStatus(com.github.jakz.romlib.data.game.GameStatus) KeyEvent(java.awt.event.KeyEvent) List(java.util.List) Drawable(com.github.jakz.romlib.data.game.Drawable) JRadioButtonMenuItem(javax.swing.JRadioButtonMenuItem) Comparator(java.util.Comparator) Pair(com.pixbits.lib.lang.Pair) ActionListener(java.awt.event.ActionListener) ButtonGroup(javax.swing.ButtonGroup) JRadioButtonMenuItem(javax.swing.JRadioButtonMenuItem) JCheckBoxMenuItem(javax.swing.JCheckBoxMenuItem) JMenu(javax.swing.JMenu)

Example 3 with GameStatus

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);
    }
}
Also used : GameStatus(com.github.jakz.romlib.data.game.GameStatus)

Aggregations

GameStatus (com.github.jakz.romlib.data.game.GameStatus)3 Drawable (com.github.jakz.romlib.data.game.Drawable)2 Game (com.github.jakz.romlib.data.game.Game)2 Attribute (com.github.jakz.romlib.data.game.attributes.Attribute)2 GameAttribute (com.github.jakz.romlib.data.game.attributes.GameAttribute)2 Feature (com.github.jakz.romlib.data.set.Feature)2 GameSet (com.github.jakz.romlib.data.set.GameSet)2 StreamUtil (com.pixbits.lib.functional.StreamUtil)2 Pair (com.pixbits.lib.lang.Pair)2 GameListData (jack.rm.gui.gamelist.GameListData)2 Text (jack.rm.i18n.Text)2 ActionListener (java.awt.event.ActionListener)2 KeyEvent (java.awt.event.KeyEvent)2 Arrays (java.util.Arrays)2 Comparator (java.util.Comparator)2 List (java.util.List)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 BiFunction (java.util.function.BiFunction)2 Predicate (java.util.function.Predicate)2 ButtonGroup (javax.swing.ButtonGroup)2