Package de.ailis.xadrian.support

Examples of de.ailis.xadrian.support.Config


    private void calculateBaseComplex()
    {
        final FactoryFactory factoryFactory = this.game.getFactoryFactory();
        final RaceFactory raceFactory = this.game.getRaceFactory();
        final Ware crystals = this.game.getWareFactory().getWare("crystals");
        final Config config = Config.getInstance();
        long currentPrice;
        long price;
        final List<ComplexFactory> backup = new ArrayList<ComplexFactory>();

        // First of all remove all automatically added factories
        this.autoFactories.clear();
        updateShoppingList();

        if (!this.addBaseComplex) return;

        // First of all we build a base complex without specific crystal fab
        // race and remember the price
        while (true)
            if (!addBaseComplex(null)) break;
        currentPrice = getTotalPrice();

        // Now cycle over all races and check if the complex gets cheaper if
        // the crystal fabs are bought from them
        for (final Race race: raceFactory.getRaces())
        {
            // If race is ignored then don't use it
            if (config.isRaceIgnored(race)) continue;

            // If race has no crystal fabs then don't use it
            if (!factoryFactory.hasFactories(race, crystals)) continue;

            // Backup current automatically added factories, clear the
View Full Code Here


     * Creates a new factory complex tab
     */
    public void createComplexTab()
    {
        // Try to read game from the configuration
        final Config config = Config.getInstance();
        final String defaultGameId = config.getDefaultGame();
        final GameFactory gameFactory = GameFactory.getInstance();
        Game game = defaultGameId == null ||
            !gameFactory.hasGame(defaultGameId) ? null
            : gameFactory.getGame(defaultGameId);

        // If no default game is set then ask for it
        if (game == null)
        {
            final SelectGameDialog dialog = SelectGameDialog.getInstance();
            if (dialog.open() != Result.OK) return;
            game = dialog.getGame();
            if (dialog.isRemember()) config.setDefaultGame(game.getId());
        }
        createComplexTab(new ComplexEditor(new Complex(game)));
    }
View Full Code Here

     * @see de.ailis.xadrian.support.ModalDialog#open()
     */
    @Override
    public Result open()
    {
        final Config config = Config.getInstance();

        // Load preference values
        for (final Map.Entry<Race, JCheckBox> entry : this.racesCheckBoxes
            .entrySet())
        {
            final Race race = entry.getKey();
            final JCheckBox checkBox = entry.getValue();
            checkBox.setSelected(!config.isRaceIgnored(race));
        }
        this.showFactoryResourcesCheckBox.setSelected(config
            .isShowFactoryResources());
        this.nightModeCheckBox.setSelected(config
            .isNightMode());
        this.themeComboBox.setSelectedItem(ThemeFactory.getInstance().getTheme(
            UIManager.getLookAndFeel().getClass().getName()));
        this.localeComboBox.setSelectedItem(new ComboBoxEntry(null,
            config.getLocale()));
        this.prodStatsComboBox.setSelectedItem(new ComboBoxEntry(null,
            config.isProdStatsPerMinute()));
        this.x3tcPlayerSectorComboBox.setSelectedIndex(config.getX3TCPlayerSector());
        this.x3apPlayerSectorComboBox.setSelectedIndex(config.getX3APPlayerSector());

        final String defaultGameId = config.getDefaultGame();
        final GameFactory gameFactory = GameFactory.getInstance();
        if (defaultGameId == null || !gameFactory.hasGame(defaultGameId))
            this.gamesComboBox.setSelectedIndex(0);
        else
            this.gamesComboBox.setSelectedItem(GameFactory.getInstance()
                .getGame(defaultGameId));

        final Result result = super.open();
        if (result == Result.OK)
        {
            // Save preference values
            for (final Map.Entry<Race, JCheckBox> entry : this.racesCheckBoxes
                .entrySet())
            {
                final Race race = entry.getKey();
                final JCheckBox checkBox = entry.getValue();
                config.setRaceIgnored(race, !checkBox.isSelected());
            }
            for (final Game game : GameFactory.getInstance().getGames())
            {
                game.getAddFactoryDialog().resetFactoriesTreeModel();
            }
            config.setShowFactoryResources(this.showFactoryResourcesCheckBox
                .isSelected());
            config.setNightMode(this.nightModeCheckBox.isSelected());
            config.setX3TCPlayerSector(
                this.x3tcPlayerSectorComboBox.getSelectedIndex());
            config.setX3APPlayerSector(
                this.x3apPlayerSectorComboBox.getSelectedIndex());
            config.setTheme(((Theme) this.themeComboBox.getSelectedItem())
                .getClassName());
            config.setLocale((String) ((ComboBoxEntry)
                this.localeComboBox.getSelectedItem()).getValue());
            config.setProdStatsPerMinute((Boolean) ((ComboBoxEntry)
                this.prodStatsComboBox.getSelectedItem()).getValue());
            if (this.gamesComboBox.getSelectedIndex() == 0)
                config.setDefaultGame(null);
            else
                config.setDefaultGame(((Game) this.gamesComboBox
                    .getSelectedItem()).getId());
        }
        return result;
    }
View Full Code Here

     */
    private void redraw()
    {
        final int c = this.textPane.getCaretPosition();
        final Map<String, Object> model = new HashMap<String, Object>();
        final Config config = Config.getInstance();
        model.put("complex", this.complex);
        model.put("print", false);
        model.put("config", config);
        final String content = TemplateFactory.processTemplate(template, model);
        this.textPane.setText(content);
View Full Code Here

     * @return The nearest sector with a shipyard selling complex construction
     *         kits or null if none.
     */
    public Sector getNearestKitSellingSector()
    {
        final Config config = Config.getInstance();
        final Set<Sector> seen = new HashSet<Sector>();
        Set<Sector> todo = new HashSet<Sector>();

        // We begin with the current sector
        todo.add(this);

        // This loop is repeated until no more TODOs are present. If the
        // target sector is reached then the loop is exited with a return
        while (todo.size() > 0)
        {
            final Set<Sector> newTodo = new HashSet<Sector>();
            for (final Sector sector : todo)
            {
                // When we have reached a sector with a shipyard and the player
                // can buy complex construction kits from it then return it.
                if (sector.hasShipyard()
                    && !config.isRaceIgnored(sector.getRace())
                    && !sector.getRace().getId().equals("xenon")                  
                    && (!sector.getRace().getId().equals("terran")
                        || !this.game.isX3TC())) return sector;

                // Mark this sector as already seen
View Full Code Here

     * @return The nearest manufacturer sector
     */
    public Sector getNearestManufacturer(final Sector sector, final boolean
        allRaces)
    {
        final Config config = Config.getInstance();
        int distance = 0;
        Sector nearest = null;

        for (final Sector manufacturer : this.manufacturers)
        {
            final int curDistance = sector.getDistance(manufacturer);
            if (nearest == null || curDistance < distance &&
                (!config.isRaceIgnored(manufacturer.getRace()) || allRaces))
            {
                nearest = manufacturer;
                distance = curDistance;
            }
        }
View Full Code Here

TOP

Related Classes of de.ailis.xadrian.support.Config

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.