You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ImageListForPreLoad.java 3.2 KiB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. package utils;
  2. import java.io.File;
  3. import java.util.ArrayList;
  4. import java.util.HashSet;
  5. import java.util.List;
  6. import java.util.Set;
  7. import structures.basic.Card;
  8. import structures.basic.Tile;
  9. import structures.basic.Unit;
  10. /**
  11. * This is a utility class that builds a large set of image URLs
  12. *
  13. * @author Dr. Richard McCreadie
  14. *
  15. */
  16. public class ImageListForPreLoad {
  17. /**
  18. * This method returns a very big list of relative locations of the different images
  19. * that are needed by the game. Pixi.js will cache these on game load.
  20. * @return
  21. */
  22. public static Set<String> getImageListForPreLoad() {
  23. Set<String> images = new HashSet<String>();
  24. // UI Elements
  25. images.add("assets/game/extra/battlemap6_middleground.png");
  26. images.add("assets/game/extra/AttackCircle.png");
  27. images.add("assets/game/extra/HealthCircle.png");
  28. images.add("assets/game/extra/GreyCircle.png");
  29. images.add("assets/game/extra/ManaCircle.png");
  30. images.add("assets/game/extra/ui/icon_mana.png");
  31. images.add("assets/game/extra/ui/icon_mana_inactive.png");
  32. images.add("assets/game/extra/ui/notification_quest_small.png");
  33. images.add("assets/game/extra/ui/general_portrait_image_hex_f1-third@2x.png");
  34. images.add("assets/game/extra/ui/general_portrait_image_hex_f4-third@2x.png");
  35. images.add("assets/game/extra/ui/tooltip_left@2x.png");
  36. images.add("assets/game/extra/ui/tooltip_right@2x.png");
  37. images.add("assets/game/extra/ui/button_end_turn_enemy.png");
  38. images.add("assets/game/extra/ui/button_primary.png");
  39. // Tiles
  40. images.addAll(Tile.constructTile(StaticConfFiles.tileConf).getTileTextures());
  41. // Avatars
  42. images.addAll(BasicObjectBuilders.loadUnit(StaticConfFiles.humanAvatar, -1, Unit.class).getAnimations().getAllFrames());
  43. images.addAll(BasicObjectBuilders.loadUnit(StaticConfFiles.aiAvatar, -1, Unit.class).getAnimations().getAllFrames());
  44. String cardsDIR = "conf/gameconfs/cards/";
  45. for (String filename : new File(cardsDIR).list()) {
  46. images.addAll(getCardImagesForPreload(cardsDIR+filename));
  47. }
  48. String unitsDIR = "conf/gameconfs/units/";
  49. for (String filename : new File(unitsDIR).list()) {
  50. images.addAll(getUnitImagesForPreload(BasicObjectBuilders.loadUnit(unitsDIR+filename, -1, Unit.class)));
  51. }
  52. String effectsDIR = "conf/gameconfs/effects/";
  53. for (String filename : new File(effectsDIR).list()) {
  54. images.addAll(BasicObjectBuilders.loadEffect(effectsDIR+filename).getAnimationTextures());
  55. }
  56. return images;
  57. }
  58. public static List<String> getUnitImagesForPreload(Unit unit) {
  59. List<String> images = unit.getAnimations().getAllFrames();
  60. return images;
  61. }
  62. public static List<String> getCardImagesForPreload(String configFile) {
  63. Card card = BasicObjectBuilders.loadCard(configFile, 0, Card.class);
  64. List<String> images = new ArrayList<String>(card.getMiniCard().getAnimationFrames().length+card.getMiniCard().getCardTextures().length+card.getBigCard().getCardTextures().length);
  65. for (String image : card.getMiniCard().getAnimationFrames()) images.add(image);
  66. for (String image : card.getMiniCard().getCardTextures()) images.add(image);
  67. for (String image :card.getBigCard().getCardTextures()) images.add(image);
  68. return images;
  69. }
  70. }