MCPcopy Create free account
hub / github.com/Card-Forge/forge / initialize

Method initialize

forge-gui/src/main/java/forge/model/FModel.java:146–267  ·  view source on GitHub ↗
(final IProgressBar progressBar, Function<ForgePreferences, Void> adjustPrefs)

Source from the content-addressed store, hash-verified

144 private static final Supplier<ItemPool<PaperCard>> contraptionPool = Suppliers.memoize(() -> ItemPool.createFrom(getMagicDb().getVariantCards().getAllCards(PaperCardPredicates.fromRules(CardRulesPredicates.IS_CONTRAPTION)), PaperCard.class));
145
146 public static void initialize(final IProgressBar progressBar, Function<ForgePreferences, Void> adjustPrefs) {
147 ImageKeys.initializeDirs(
148 ForgeConstants.CACHE_CARD_PICS_DIR, ForgeConstants.CACHE_CARD_PICS_SUBDIR,
149 ForgeConstants.CACHE_TOKEN_PICS_DIR, ForgeConstants.CACHE_ICON_PICS_DIR,
150 ForgeConstants.CACHE_BOOSTER_PICS_DIR, ForgeConstants.CACHE_FATPACK_PICS_DIR,
151 ForgeConstants.CACHE_BOOSTERBOX_PICS_DIR, ForgeConstants.CACHE_PRECON_PICS_DIR,
152 ForgeConstants.CACHE_TOURNAMENTPACK_PICS_DIR);
153
154 // Instantiate preferences: quest and regular
155 // Preferences are initialized first so that the splash screen can be translated.
156 try {
157 if (adjustPrefs != null) {
158 adjustPrefs.apply(getPreferences());
159 }
160 GamePlayerUtil.getGuiPlayer().setName(getPreferences().getPref(FPref.PLAYER_NAME));
161 }
162 catch (final Exception exn) {
163 throw new RuntimeException(exn);
164 }
165
166 // Runs here because preferences must be loaded before MAX_LOG_FILES is readable
167 ExceptionHandler.pruneForgeLogs(getPreferences().getPrefInt(FPref.MAX_LOG_FILES));
168
169 Lang.createInstance(getPreferences().getPref(FPref.UI_LANGUAGE));
170 Localizer.getInstance().initialize(getPreferences().getPref(FPref.UI_LANGUAGE), ForgeConstants.LANG_DIR);
171
172 final ProgressObserver progressBarBridge = (progressBar == null) ?
173 ProgressObserver.emptyObserver : new ProgressObserver() {
174 @Override
175 public void setOperationName(final String name, final boolean usePercents) {
176 FThreads.invokeInEdtLater(() -> {
177 progressBar.setDescription(name);
178 progressBar.setPercentMode(usePercents);
179 });
180 }
181
182 @Override
183 public void report(final int current, final int total) {
184 FThreads.invokeInEdtLater(() -> {
185 progressBar.setMaximum(total);
186 progressBar.setValue(current);
187 });
188 }
189 };
190
191 // if (new AutoUpdater(true).attemptToUpdate()) {}
192 // Load types before loading cards
193 loadDynamicGamedata();
194
195 // Load card database
196 // Lazy loading currently disabled
197 reader = new CardStorageReader(ForgeConstants.CARD_DATA_DIR, progressBarBridge,
198 false);
199 tokenReader = new CardStorageReader(ForgeConstants.TOKEN_DATA_DIR, progressBarBridge,
200 false);
201
202 try {
203 customReader = new CardStorageReader(ForgeConstants.USER_CUSTOM_CARDS_DIR, progressBarBridge, false);

Callers 11

createMethod · 0.95
mainMethod · 0.95
initializeModelMethod · 0.95
testMethod · 0.95
testMethod · 0.95
testMethod · 0.95
testMethod · 0.95
testMethod · 0.95
initializeOnceMethod · 0.95
simulateMethod · 0.95

Calls 15

initializeDirsMethod · 0.95
getPreferencesMethod · 0.95
getGuiPlayerMethod · 0.95
pruneForgeLogsMethod · 0.95
createInstanceMethod · 0.95
getInstanceMethod · 0.95
loadDynamicGamedataMethod · 0.95
preloadTranslationMethod · 0.95
getMagicDbMethod · 0.95
getFormatsMethod · 0.95
setPerformanceModeMethod · 0.95
invokeInEdtLaterMethod · 0.95

Tested by 7

initializeModelMethod · 0.76
testMethod · 0.76
testMethod · 0.76
testMethod · 0.76
testMethod · 0.76
testMethod · 0.76