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

Method loadAsset

forge-gui-mobile/src/forge/assets/ImageCache.java:350–393  ·  view source on GitHub ↗
(String imageKey, File file, boolean others)

Source from the content-addressed store, hash-verified

348 }
349
350 private Texture loadAsset(String imageKey, File file, boolean others) {
351 if (file == null)
352 return null;
353 Texture check = getAsset(file);
354 if (check != null)
355 return check;
356 if (!others) {
357 //update first before clearing
358 getSyncQ().add(file.getPath());
359 getCardsLoaded().add(file.getPath());
360 unloadCardTextures(false);
361 }
362 String fileName = file.getPath();
363 //load to assetmanager
364 try {
365 if (Forge.getAssets().manager().get(fileName, Texture.class, false) == null) {
366 Forge.getAssets().manager().load(fileName, Texture.class, Forge.getAssets().getTextureFilter());
367 Forge.getAssets().manager().finishLoadingAsset(fileName);
368 counter += 1;
369 }
370 } catch (Exception e) {
371 System.err.println("Failed to load image: " + fileName);
372 }
373
374 //return loaded assets
375 if (others) {
376 return Forge.getAssets().manager().get(fileName, Texture.class, false);
377 } else {
378 Texture cardTexture = Forge.getAssets().manager().get(fileName, Texture.class, false);
379 //if full bordermasking is enabled, update the border color
380 if (cardTexture != null) {
381 String setCode = imageKey.split("/")[0].trim().toUpperCase();
382 int radius;
383 if (setCode.equals("A") || setCode.equals("LEA") || setCode.equals("B") || setCode.equals("LEB"))
384 radius = 28;
385 else if (setCode.equals("MED") || setCode.equals("ME2") || setCode.equals("ME3") || setCode.equals("ME4") || setCode.equals("TD0") || setCode.equals("TD1"))
386 radius = 25;
387 else
388 radius = 22;
389 updateImageRecord(cardTexture.toString(), isCloserToWhite(getpixelColor(cardTexture)), radius, cardTexture.toString().contains(".fullborder.") || cardTexture.toString().contains("tokens"));
390 }
391 return cardTexture;
392 }
393 }
394
395 public void unloadCardTextures(boolean removeAll) {
396 if (removeAll) {

Callers 1

getImageMethod · 0.95

Calls 15

getAssetMethod · 0.95
getSyncQMethod · 0.95
getCardsLoadedMethod · 0.95
unloadCardTexturesMethod · 0.95
getAssetsMethod · 0.95
updateImageRecordMethod · 0.95
isCloserToWhiteMethod · 0.95
getpixelColorMethod · 0.95
managerMethod · 0.80
getTextureFilterMethod · 0.80
finishLoadingAssetMethod · 0.80
splitMethod · 0.80

Tested by

no test coverage detected