(final File pcpFile)
| 1191 | } |
| 1192 | |
| 1193 | public void loadPartyFromFile(final File pcpFile) |
| 1194 | { |
| 1195 | if (!PCGFile.isPCGenPartyFile(pcpFile)) |
| 1196 | { |
| 1197 | this.showErrorMessage(LanguageBundle.getString("in_loadPartyFailTtile"), |
| 1198 | LanguageBundle.getFormattedString("in_loadPartyInvalid", pcpFile) ); |
| 1199 | return; |
| 1200 | } |
| 1201 | if (!pcpFile.canRead()) |
| 1202 | { |
| 1203 | this.showErrorMessage(LanguageBundle.getString("in_loadPartyFailTtile"), |
| 1204 | LanguageBundle.getFormattedString("in_loadPartyNoRead", pcpFile) ); |
| 1205 | return; |
| 1206 | } |
| 1207 | SourceSelectionFacade sources = CharacterManager.getRequiredSourcesForParty(pcpFile, this); |
| 1208 | if (sources == null) |
| 1209 | { |
| 1210 | this.showErrorMessage(LanguageBundle.getString("in_loadPartyFailTtile"), |
| 1211 | LanguageBundle.getFormattedString("in_loadPartyNoSources", pcpFile) ); |
| 1212 | } |
| 1213 | else if (!sources.getCampaigns().isEmpty()) |
| 1214 | { |
| 1215 | // Check if the user has asked that sources not be loaded with the character |
| 1216 | boolean dontLoadSources = currentSourceSelection.get() != null |
| 1217 | && !PCGenSettings.OPTIONS_CONTEXT.initBoolean(PCGenSettings.OPTION_AUTOLOAD_SOURCES_WITH_PC, true); |
| 1218 | if (dontLoadSources) |
| 1219 | { |
| 1220 | if (!checkSourceEquality(sources, currentSourceSelection.get())) |
| 1221 | { |
| 1222 | Logging.log(Logging.WARNING, "Loading party with different sources. Party: " + sources |
| 1223 | + " current: " + currentSourceSelection.get()); |
| 1224 | } |
| 1225 | CharacterManager.openParty(pcpFile, PCGenFrame.this, currentDataSetRef.get()); |
| 1226 | } |
| 1227 | else if (loadSourceSelection(sources)) |
| 1228 | { |
| 1229 | new Thread(() -> { |
| 1230 | try |
| 1231 | { |
| 1232 | sourceLoader.join(); |
| 1233 | SwingUtilities.invokeLater(() -> CharacterManager.openParty(pcpFile, PCGenFrame.this, currentDataSetRef.get())); |
| 1234 | } |
| 1235 | catch (InterruptedException ex) |
| 1236 | { |
| 1237 | //Do nothing |
| 1238 | } |
| 1239 | }).start(); |
| 1240 | } |
| 1241 | else |
| 1242 | { |
| 1243 | this.showErrorMessage(LanguageBundle.getString("in_loadPartyFailTtile"), |
| 1244 | LanguageBundle.getString("in_loadPcIncompatSource") ); |
| 1245 | } |
| 1246 | } |
| 1247 | } |
| 1248 | |
| 1249 | /** |
| 1250 | * Set the frame's title based on the current character and source/game mode. |
no test coverage detected