|
1 | 1 | package cwlib.enums; |
2 | 2 |
|
| 3 | +import java.util.Arrays; |
| 4 | + |
| 5 | +import javax.management.RuntimeErrorException; |
| 6 | + |
| 7 | +import cwlib.CwlibConfiguration; |
| 8 | +import cwlib.resources.RGfxMaterial; |
| 9 | +import cwlib.types.data.Revision; |
| 10 | + |
3 | 11 | public enum GameShader |
4 | 12 | { |
5 | | - LBP1, |
6 | | - LBP2_PRE_ALPHA, |
7 | | - LBP2, |
8 | | - LBP3_PS4, |
9 | | - LBP_STUPID_BUILD, |
10 | | - VITA |
| 13 | + LBP1("LBP1", new Revision(Revisions.LBP1_MAX, Branch.LEERDAMMER.getID(), Revisions.LD_SHADER)), |
| 14 | + LBP_STUPID_BUILD("LBP1 Private Beta", new Revision(0x132)), |
| 15 | + LBP2_PRE_ALPHA("LBP2 Pre-Alpha", new Revision(0x332)), |
| 16 | + LBP2("LBP2", new Revision(0x393)), |
| 17 | + LBP3_PS4("LBP3 PS4", new Revision(0x393)), |
| 18 | + VITA("LBP Vita", new Revision(Branch.DOUBLE11.getHead(), Branch.DOUBLE11.getID(), Branch.DOUBLE11.getRevision())); |
| 19 | + |
| 20 | + public static GameShader[] COMPILABLE = Arrays.asList(GameShader.values()).stream().filter(x -> x.compilable()).toArray(GameShader[]::new); |
| 21 | + |
| 22 | + private final String name; |
| 23 | + private final Revision revision; |
| 24 | + private GameShader(String name, Revision revision) |
| 25 | + { |
| 26 | + this.name = name; |
| 27 | + this.revision = revision; |
| 28 | + } |
| 29 | + |
| 30 | + public String getName() { return name; } |
| 31 | + public Revision getRevision() { return revision; } |
| 32 | + |
| 33 | + public boolean hasAlphaMode() |
| 34 | + { |
| 35 | + return this != LBP1 && this != LBP_STUPID_BUILD; |
| 36 | + } |
| 37 | + |
| 38 | + public int getShaderCount() |
| 39 | + { |
| 40 | + switch (this) |
| 41 | + { |
| 42 | + case LBP1: |
| 43 | + return 4; |
| 44 | + case LBP_STUPID_BUILD: |
| 45 | + return 3; |
| 46 | + case LBP2: |
| 47 | + case LBP3_PS4: |
| 48 | + return 10; |
| 49 | + case LBP2_PRE_ALPHA: |
| 50 | + return 4; |
| 51 | + case VITA: |
| 52 | + return 24; |
| 53 | + default: |
| 54 | + throw new RuntimeException("Just to make the compiler happy!"); |
| 55 | + } |
| 56 | + } |
| 57 | + |
| 58 | + public boolean compilable() |
| 59 | + { |
| 60 | + if (this == LBP3_PS4) return CwlibConfiguration.CAN_COMPILE_ORBIS_SHADERS; |
| 61 | + if (this == VITA) return CwlibConfiguration.CAN_COMPILE_PSP2_SHADERS; |
| 62 | + return CwlibConfiguration.CAN_COMPILE_CELL_SHADERS; |
| 63 | + } |
| 64 | + |
| 65 | + @Override public String toString() { return name; } |
| 66 | + |
| 67 | + public static GameShader fromMaterial(RGfxMaterial material, Revision revision) |
| 68 | + { |
| 69 | + if (revision.isLBP3()) |
| 70 | + return material.shaders[0][0x25] == 'h' ? GameShader.LBP3_PS4 : GameShader.LBP2; |
| 71 | + |
| 72 | + int version = revision.getVersion(); |
| 73 | + if (version == 0x132) |
| 74 | + return GameShader.LBP_STUPID_BUILD; |
| 75 | + |
| 76 | + if (revision.isVita()) |
| 77 | + return GameShader.VITA; |
| 78 | + |
| 79 | + if (revision.isLBP2()) |
| 80 | + return version < 0x34f ? GameShader.LBP2_PRE_ALPHA : GameShader.LBP2; |
| 81 | + |
| 82 | + return GameShader.LBP1; |
| 83 | + } |
11 | 84 | } |
0 commit comments