Skip to content

Commit e464e1f

Browse files
committed
quick recompile/edit shader
1 parent faaf7fa commit e464e1f

6 files changed

Lines changed: 434 additions & 502 deletions

File tree

lib/cwlib/src/main/java/cwlib/CwlibConfiguration.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,11 @@ public class CwlibConfiguration
7171
*/
7272
public static boolean CAN_COMPILE_PSP2_SHADERS = false;
7373

74+
/**
75+
* Whether or not we're able to compile at least one shader source.
76+
*/
77+
public static boolean CAN_COMPILE_ANY_SHADER_SOURCE = false;
78+
7479
/**
7580
* Whether Toolkit is running on Windows
7681
*/
@@ -90,5 +95,7 @@ public class CwlibConfiguration
9095
CAN_COMPILE_CELL_SHADERS = SCE_CGC_EXECUTABLE.exists();
9196
if (SCE_PSP2_CGC_EXECUTABLE != null)
9297
CAN_COMPILE_PSP2_SHADERS = SCE_PSP2_CGC_EXECUTABLE.exists();
98+
99+
CAN_COMPILE_ANY_SHADER_SOURCE = CAN_COMPILE_CELL_SHADERS || CAN_COMPILE_ORBIS_SHADERS || CAN_COMPILE_PSP2_SHADERS;
93100
}
94101
}
Lines changed: 79 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,84 @@
11
package cwlib.enums;
22

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+
311
public enum GameShader
412
{
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+
}
1184
}

toolkit/src/main/java/executables/gfx/GfxGUI.form

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,14 @@
1717
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="importMenuItemActionPerformed"/>
1818
</Events>
1919
</MenuItem>
20+
<MenuItem class="javax.swing.JMenuItem" name="exportMenuItem">
21+
<Properties>
22+
<Property name="text" type="java.lang.String" value="Export"/>
23+
</Properties>
24+
<Events>
25+
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="exportMenuItemActionPerformed"/>
26+
</Events>
27+
</MenuItem>
2028
<MenuItem class="javax.swing.JMenuItem" name="resetMenuItem">
2129
<Properties>
2230
<Property name="text" type="java.lang.String" value="Reset"/>
@@ -686,18 +694,15 @@
686694
<Component class="javax.swing.JComboBox" name="gameComboBox">
687695
<Properties>
688696
<Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
689-
<StringArray count="4">
690-
<StringItem index="0" value="LBP1"/>
691-
<StringItem index="1" value="LBP2 Pre-Alpha"/>
692-
<StringItem index="2" value="LBP2/3"/>
693-
<StringItem index="3" value="LBP3 PS4"/>
694-
</StringArray>
697+
<StringArray count="0"/>
695698
</Property>
699+
<Property name="toolTipText" type="java.lang.String" value=""/>
696700
</Properties>
697701
<Events>
698702
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="gameComboBoxActionPerformed"/>
699703
</Events>
700704
<AuxValues>
705+
<AuxValue name="JavaCodeGenerator_CreateCodeCustom" type="java.lang.String" value="new javax.swing.JComboBox(GameShader.COMPILABLE)"/>
701706
<AuxValue name="JavaCodeGenerator_TypeParameters" type="java.lang.String" value="&lt;String&gt;"/>
702707
</AuxValues>
703708
</Component>

0 commit comments

Comments
 (0)