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());
}
}
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);
}
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;
}
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);
}
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);
}
Aggregations