Search in sources :

Example 1 with GameMode

use of pcgen.core.GameMode in project pcgen by PCGen.

the class EquipIconLoader method parseLine.

/**
	 * @see pcgen.persistence.lst.LstLineFileLoader#parseLine(pcgen.rules.context.LoadContext, java.lang.String, java.net.URI)
	 */
@Override
public void parseLine(LoadContext context, String lstLine, URI sourceURI) throws PersistenceLayerException {
    final int idxColon = lstLine.indexOf(':');
    if (idxColon < 0) {
        return;
    }
    final GameMode game = SystemCollections.getGameModeNamed(gameMode);
    final String key = lstLine.substring(0, idxColon);
    final String value = lstLine.substring(idxColon + 1);
    Map<String, LstToken> tokenMap = TokenStore.inst().getTokenMap(EquipIconLstToken.class);
    EquipIconLstToken token = (EquipIconLstToken) tokenMap.get(key);
    if (token != null) {
        LstUtils.deprecationCheck(token, key, sourceURI, lstLine);
        if (!token.parse(game, value, sourceURI)) {
            Logging.errorPrint("Error parsing EquipIcon object: " + lstLine + " at " + sourceURI.toString());
        }
    } else {
        Logging.errorPrint("Illegal EquipIcon object: " + lstLine + " at " + sourceURI.toString());
    }
}
Also used : GameMode(pcgen.core.GameMode)

Example 2 with GameMode

use of pcgen.core.GameMode in project pcgen by PCGen.

the class BioSetLoader method loadLstFile.

/**
	 * @see pcgen.persistence.lst.LstLineFileLoader#loadLstFile(LoadContext, URI)
	 */
@Override
public void loadLstFile(LoadContext context, URI fileName) throws PersistenceLayerException {
    currentAgeSetIndex = 0;
    final GameMode game = SystemCollections.getGameModeNamed(gameMode);
    bioSet = game.getBioSet();
    super.loadLstFile(context, fileName);
    game.setBioSet(bioSet);
}
Also used : GameMode(pcgen.core.GameMode)

Example 3 with GameMode

use of pcgen.core.GameMode in project pcgen by PCGen.

the class CampaignPanel method performAnalysis.

/**
	 * @see pcgen.gui2.converter.panel.ConvertSubPanel#performAnalysis(pcgen.cdom.base.CDOMObject)
	 */
@Override
public boolean performAnalysis(CDOMObject pc) {
    GameMode game = pc.get(ObjectKey.GAME_MODE);
    List<String> gameModeList = new ArrayList<>();
    gameModeList.addAll(game.getAllowedModes());
    File sourceFolder = pc.get(ObjectKey.DIRECTORY);
    folderName = sourceFolder.toURI().toString();
    // Only add those campaigns in the user's chosen folder and game mode
    List<Campaign> allCampaigns = Globals.getCampaignList();
    gameModeCampaigns = new ArrayList<>();
    for (Campaign campaign : allCampaigns) {
        if (campaign.containsAnyInList(ListKey.GAME_MODE, gameModeList)) {
            if (campaign.getSourceURI().toString().startsWith(folderName)) {
                gameModeCampaigns.add(campaign);
            }
        }
    }
    return false;
}
Also used : GameMode(pcgen.core.GameMode) Campaign(pcgen.core.Campaign) ArrayList(java.util.ArrayList) File(java.io.File)

Example 4 with GameMode

use of pcgen.core.GameMode in project pcgen by PCGen.

the class GameModePanel method performAnalysis.

@Override
public boolean performAnalysis(CDOMObject pc) {
    File sourceDir = pc.get(ObjectKey.DIRECTORY);
    String name = sourceDir.getAbsolutePath();
    if (!name.equals(ConfigurationSettings.getPccFilesDir()) && !name.equals(PCGenSettings.getVendorDataDir()) && !name.equals(PCGenSettings.getHomebrewDataDir())) {
        // User has selected another path - we need to load the sources from there.
        Logging.log(Logging.INFO, "Loading campaigns from " + sourceDir);
        Globals.clearCampaignsForRefresh();
        campaignFileLoader.setAlternateSourceFolder(sourceDir);
        campaignFileLoader.execute();
    }
    GameMode gameMode = pc.get(ObjectKey.GAME_MODE);
    if (gameMode != null) {
        SettingsHandler.setGame(gameMode.getName());
    }
    //		Globals.emptyLists();
    Globals.sortPObjectListByName(Globals.getCampaignList());
    Globals.createEmptyRace();
    return saveGameMode(pc);
}
Also used : GameMode(pcgen.core.GameMode) File(java.io.File)

Example 5 with GameMode

use of pcgen.core.GameMode in project pcgen by PCGen.

the class GameModePanel method setupDisplay.

@Override
public void setupDisplay(JPanel panel, final CDOMObject pc) {
    panel.setLayout(layout);
    JLabel introLabel = new JLabel("Please select the Game Mode to Convert:");
    panel.add(introLabel);
    layout.putConstraint(SpringLayout.NORTH, introLabel, 50, SpringLayout.NORTH, panel);
    layout.putConstraint(SpringLayout.WEST, introLabel, 25, SpringLayout.WEST, panel);
    List<GameMode> games = SystemCollections.getUnmodifiableGameModeList();
    gameModeCombo = new JComboBoxEx(games.toArray());
    gameModeCombo.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent arg0) {
            getSelection(pc);
            saveGameMode(pc);
        }
    });
    PCGenSettings context = PCGenSettings.getInstance();
    SettingsHandler.setGame(context.initProperty(PCGenSettings.CONVERT_GAMEMODE, SettingsHandler.getGame().getName()));
    GameMode currGame = SettingsHandler.getGame();
    if (pc.get(ObjectKey.GAME_MODE) != null) {
        currGame = pc.get(ObjectKey.GAME_MODE);
    }
    gameModeCombo.setSelectedItem(currGame);
    getSelection(pc);
    saveGameMode(pc);
    panel.add(gameModeCombo);
    layout.putConstraint(SpringLayout.NORTH, gameModeCombo, 20, SpringLayout.SOUTH, introLabel);
    layout.putConstraint(SpringLayout.WEST, gameModeCombo, 25, SpringLayout.WEST, panel);
}
Also used : GameMode(pcgen.core.GameMode) ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) JLabel(javax.swing.JLabel) JComboBoxEx(pcgen.gui2.util.JComboBoxEx) PCGenSettings(pcgen.system.PCGenSettings)

Aggregations

GameMode (pcgen.core.GameMode)58 PCStat (pcgen.core.PCStat)10 PlayerCharacter (pcgen.core.PlayerCharacter)8 File (java.io.File)7 Campaign (pcgen.core.Campaign)7 LoadContext (pcgen.rules.context.LoadContext)7 LevelInfo (pcgen.core.LevelInfo)6 Race (pcgen.core.Race)6 AbstractReferenceContext (pcgen.rules.context.AbstractReferenceContext)6 ArrayList (java.util.ArrayList)5 PCClass (pcgen.core.PCClass)5 BonusObj (pcgen.core.bonus.BonusObj)4 Before (org.junit.Before)3 Equipment (pcgen.core.Equipment)3 CampaignFacade (pcgen.facade.core.CampaignFacade)3 FileWriter (java.io.FileWriter)2 IOException (java.io.IOException)2 Writer (java.io.Writer)2 HashMap (java.util.HashMap)2 JLabel (javax.swing.JLabel)2