Search in sources :

Example 1 with CartridgeFormat

use of org.javatari.atari.cartridge.CartridgeFormat in project javatari by ppeccin.

the class JComboBoxNim method refreshCartridge.

private void refreshCartridge() {
    if (refreshInProgress)
        return;
    refreshInProgress = true;
    if (room.currentConsole().cartridgeSocket().inserted() == null) {
        romNameTf.setText("<NO CARTRIDGE INSERTED>");
        romFormatLb.setListData(new Object[0]);
        romFormatLb.setEnabled(false);
        defaultsB.setVisible(false);
    } else {
        Cartridge cart = room.currentConsole().cartridgeSocket().inserted();
        romNameTf.setText(cart.rom().info.name);
        romNameTf.setCaretPosition(0);
        ArrayList<CartridgeFormat> formats = new ArrayList<CartridgeFormat>();
        try {
            ArrayList<CartridgeFormatOption> formatOptions;
            formatOptions = CartridgeDatabase.getFormatOptions(cart.rom());
            for (CartridgeFormatOption option : formatOptions) formats.add(option.format);
        } catch (ROMFormatUnsupportedException e) {
        // Leave formats empty
        }
        if (!formats.contains(cart.format()))
            formats.add(0, cart.format());
        romFormatLb.setListData(formats.toArray());
        romFormatLb.setSelectedValue(cart.format(), true);
        romFormatLb.setEnabled(!formats.isEmpty() && !room.isClientMode());
        defaultsB.setText("Auto Detect");
        defaultsB.setVisible(!room.isClientMode());
    }
    refreshInProgress = false;
}
Also used : Cartridge(org.javatari.atari.cartridge.Cartridge) CartridgeFormat(org.javatari.atari.cartridge.CartridgeFormat) ArrayList(java.util.ArrayList) CartridgeFormatOption(org.javatari.atari.cartridge.CartridgeFormatOption) ROMFormatUnsupportedException(org.javatari.atari.cartridge.ROMFormatUnsupportedException)

Example 2 with CartridgeFormat

use of org.javatari.atari.cartridge.CartridgeFormat in project javatari by ppeccin.

the class JComboBoxNim method romFormatLbAction.

private void romFormatLbAction() {
    Object sel = romFormatLb.getSelectedValue();
    if (sel == null || !(sel instanceof CartridgeFormat))
        return;
    CartridgeFormat format = (CartridgeFormat) sel;
    Console console = room.currentConsole();
    Cartridge cart = console.cartridgeSocket().inserted();
    if (cart == null || cart.format().equals(format))
        return;
    Cartridge newCart = format.createCartridge(cart.rom());
    console.cartridgeSocket().insert(newCart, true);
}
Also used : Cartridge(org.javatari.atari.cartridge.Cartridge) CartridgeFormat(org.javatari.atari.cartridge.CartridgeFormat) Console(org.javatari.atari.console.Console)

Aggregations

Cartridge (org.javatari.atari.cartridge.Cartridge)2 CartridgeFormat (org.javatari.atari.cartridge.CartridgeFormat)2 ArrayList (java.util.ArrayList)1 CartridgeFormatOption (org.javatari.atari.cartridge.CartridgeFormatOption)1 ROMFormatUnsupportedException (org.javatari.atari.cartridge.ROMFormatUnsupportedException)1 Console (org.javatari.atari.console.Console)1