Search in sources :

Example 1 with GameClone

use of com.github.jakz.romlib.data.game.GameClone in project rom-manager by Jakz.

the class ClonesEnumPanel method update.

public void update(final Game game) {
    Runnable updater = () -> {
        inner.removeAll();
        // inner.setLayout(mode == Mode.COMPACT ? new FlowLayout() : new BoxLayout(inner, BoxLayout.PAGE_AXIS));
        inner.setLayout(new WrapLayout());
        this.game = game;
        if (game != null) {
            GameClone clones = game.getClone();
            if (clones != null) {
                this.clones = clones.stream().toArray(i -> new Game[i]);
                // title.setText("Clones: "+this.clones.length);
                inner.add(new JLabel("" + this.clones.length + " clones:"));
                for (final Game clone : this.clones) {
                    JButton label = new JButton();
                    label.setFocusPainted(false);
                    label.setContentAreaFilled(false);
                    label.setOpaque(false);
                    Icon icon = clone.getLocation().getIcon();
                    label.setIcon(icon != null ? icon.getIcon() : null);
                    label.setText(mode == Mode.COMPACT ? clone.getVersion().toString() : clone.getCorrectName());
                    // if (game == clone)
                    // label.setFont(label.getFont().deriveFont(Font.BOLD));
                    label.setForeground(clone.getStatus().color);
                    if (game == clone)
                        label.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(Color.DARK_GRAY, 2), BorderFactory.createEmptyBorder(4, 4, 4, 4)));
                    else
                        label.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(Color.GRAY), BorderFactory.createEmptyBorder(5, 5, 5, 5)));
                    label.setToolTipText(clone.getCorrectName());
                    label.addActionListener(e -> {
                        if (game != clone)
                            mediator.selectGameIfVisible(clone);
                    });
                    inner.add(label);
                }
                revalidate();
                repaint();
                return;
            }
        }
        title.setText("");
        revalidate();
        repaint();
        return;
    };
    if (SwingUtilities.isEventDispatchThread())
        updater.run();
    else
        SwingUtilities.invokeLater(updater);
}
Also used : Color(java.awt.Color) JComponent(javax.swing.JComponent) FlowLayout(java.awt.FlowLayout) Insets(java.awt.Insets) Icon(com.github.jakz.romlib.ui.Icon) JButton(javax.swing.JButton) Font(java.awt.Font) WrapLayout(com.pixbits.lib.ui.WrapLayout) Game(com.github.jakz.romlib.data.game.Game) BorderFactory(javax.swing.BorderFactory) MouseEvent(java.awt.event.MouseEvent) GameSet(com.github.jakz.romlib.data.set.GameSet) Dimension(java.awt.Dimension) SwingUtilities(javax.swing.SwingUtilities) JLabel(javax.swing.JLabel) MouseAdapter(java.awt.event.MouseAdapter) GameClone(com.github.jakz.romlib.data.game.GameClone) BorderLayout(java.awt.BorderLayout) JPanel(javax.swing.JPanel) BoxLayout(javax.swing.BoxLayout) Mediator(jack.rm.gui.Mediator) Game(com.github.jakz.romlib.data.game.Game) JButton(javax.swing.JButton) JLabel(javax.swing.JLabel) GameClone(com.github.jakz.romlib.data.game.GameClone) Icon(com.github.jakz.romlib.ui.Icon) WrapLayout(com.pixbits.lib.ui.WrapLayout)

Example 2 with GameClone

use of com.github.jakz.romlib.data.game.GameClone in project rom-manager by Jakz.

the class GameTree method fireChanges.

public void fireChanges() {
    if (data.getMode() == GameListData.Mode.CLONES)
        root = new GameTreeNode.RootNode(data.stream().map(d -> (GameClone) d));
    else
        root = null;
    this.addTreeSelectionListener(new Listener());
    model.setRoot(root);
    model.nodeStructureChanged(root);
}
Also used : TreeSelectionListener(javax.swing.event.TreeSelectionListener) TreeNode(javax.swing.tree.TreeNode) GameNode(jack.rm.gui.gamelist.GameTreeNode.GameNode) CloneNode(jack.rm.gui.gamelist.GameTreeNode.CloneNode) Game(com.github.jakz.romlib.data.game.Game) GameClone(com.github.jakz.romlib.data.game.GameClone) MyGameSetFeatures(jack.rm.data.romset.MyGameSetFeatures) JTree(javax.swing.JTree) Main(jack.rm.Main) TreeSelectionEvent(javax.swing.event.TreeSelectionEvent) DefaultTreeModel(javax.swing.tree.DefaultTreeModel) Mediator(jack.rm.gui.Mediator) TreeSelectionListener(javax.swing.event.TreeSelectionListener) GameClone(com.github.jakz.romlib.data.game.GameClone)

Aggregations

Game (com.github.jakz.romlib.data.game.Game)2 GameClone (com.github.jakz.romlib.data.game.GameClone)2 Mediator (jack.rm.gui.Mediator)2 GameSet (com.github.jakz.romlib.data.set.GameSet)1 Icon (com.github.jakz.romlib.ui.Icon)1 WrapLayout (com.pixbits.lib.ui.WrapLayout)1 Main (jack.rm.Main)1 MyGameSetFeatures (jack.rm.data.romset.MyGameSetFeatures)1 CloneNode (jack.rm.gui.gamelist.GameTreeNode.CloneNode)1 GameNode (jack.rm.gui.gamelist.GameTreeNode.GameNode)1 BorderLayout (java.awt.BorderLayout)1 Color (java.awt.Color)1 Dimension (java.awt.Dimension)1 FlowLayout (java.awt.FlowLayout)1 Font (java.awt.Font)1 Insets (java.awt.Insets)1 MouseAdapter (java.awt.event.MouseAdapter)1 MouseEvent (java.awt.event.MouseEvent)1 BorderFactory (javax.swing.BorderFactory)1 BoxLayout (javax.swing.BoxLayout)1