Skip to content

Commit

Permalink
Bugfixes
Browse files Browse the repository at this point in the history
Many bugfixes related to project importing, also some for the model viewer.
Also contains many things related to shaders and materials, not included in the released version.
  • Loading branch information
emd4600 committed Feb 14, 2019
1 parent d5353aa commit bc47389
Show file tree
Hide file tree
Showing 49 changed files with 3,365 additions and 526 deletions.
23 changes: 23 additions & 0 deletions Styles/Default/syntax.css
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,27 @@
.propeditor-property {
-fx-font-weight: bold;
-fx-fill: #CE81D6;
}

/** -- HLSL -- */

.hlsl-comments {
-fx-fill: green;
}
.hlsl-enums {
-fx-fill: rgb(186, 85, 211);
}
.hlsl-numbers {
-fx-fill: #e5af25;
}
.hlsl-types {
-fx-fill: #008b8b;
}
.hlsl-keywords {
-fx-fill: rgb(0, 0, 255);
-fx-font-weight: bold;
}
.hlsl-functions {
-fx-fill: #e57402;
-fx-font-weight: bold;
}
39 changes: 38 additions & 1 deletion reg_file.txt
Original file line number Diff line number Diff line change
Expand Up @@ -77581,4 +77581,41 @@ weaponCell
weaponCharging
weaponElectro
weaponPoison
wing
wing

materials_compiled_states_link~ 0x40212000
materials_compiled_states~ 0x40212001
materials_uncompiled_shader_fragments~ 0x40212002
materials_compiled_shaders~ 0x40212004

GenericStatic
Generic2D
Particles_Decal
Particles_DecalInvertDepth
Particles_DecalIgnoreDepth
Particles_DepthDecal
Particles_Additive
Particles_AdditiveInvertDepth
Particles_AdditiveIgnoreDepth
Particles_Modulate
Particles_NormalMap
Particles_DepthNormalMap
Particles_AlphaTestDissolve
ParticlesLightFog_Decal
ParticlesLightFog_DecalInvertDepth
ParticlesLightFog_DecalIgnoreDepth
ParticlesLightFog_DepthDecal
ScreenAdditive
ScreenBlend
ScreenTint
ScreenBrighten
ScreenSkyBox
ScreenBackground
ScreenAdditiveTexture
ScreenBlendTexture
ScreenTintTexture
ScreenBrightenTexture
BuildBasis_0_0
BuildBasis_0_1
BuildBasis_1_0
BuildBasis_1_1
2 changes: 1 addition & 1 deletion reg_type.txt
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ cfx 0x278CF8F2
dds 0x17952E6C
snr 0x01a527db
sns 0x01eef63a
cpp 0x0469A3F7
smt 0x0469A3F7
eapd 0x022D2C83
package 0x06EFC6AA
instrument 0x03055F61
Expand Down
7 changes: 4 additions & 3 deletions src/sporemodder/EditorManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@

import javafx.collections.ListChangeListener;
import javafx.scene.Node;
import javafx.scene.control.ButtonType;
import javafx.scene.control.CheckBox;
import javafx.scene.control.Dialog;
import javafx.scene.control.Tab;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
Expand All @@ -49,10 +46,12 @@
import sporemodder.view.editors.PropEditorFactory;
import sporemodder.view.editors.RWModelViewer;
import sporemodder.view.editors.SearchableEditor;
import sporemodder.view.editors.SmtTextEditorFactory;
import sporemodder.view.editors.SpuiEditorFactory;
import sporemodder.view.editors.TextEditorFactory;
import sporemodder.view.editors.TlsaEditorFactory;
import sporemodder.view.editors.XmlEditorFactory;
import sporemodder.view.syntax.HlslSyntax;
import sporemodder.view.syntax.SyntaxFormatFactory;
import sporemodder.view.syntax.XmlSyntax;

Expand Down Expand Up @@ -114,6 +113,7 @@ public void initialize(Properties properties) {
// Default editors
// The default one goes first, as it will be the last one to be checked
editorFactories.add(defaultEditorFactory);
editorFactories.add(new SmtTextEditorFactory());
editorFactories.add(new XmlEditorFactory());
editorFactories.add(new PctpEditorFactory());
editorFactories.add(new TlsaEditorFactory());
Expand All @@ -126,6 +126,7 @@ public void initialize(Properties properties) {
// Default syntax highlighting
//TODO add more here!
syntaxHighlighters.add(new XmlSyntax());
syntaxHighlighters.add(new HlslSyntax());


// Load the icons for the project tree
Expand Down
2 changes: 1 addition & 1 deletion src/sporemodder/FileManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public static FileManager get() {

@Override public void initialize(Properties properties) {

searchableExtensions.addAll(Arrays.asList("prop_t", "xml", "locale", "txt", "trigger", "tlsa_t", "pctp_t", "pfx"));
searchableExtensions.addAll(Arrays.asList("prop_t", "xml", "locale", "txt", "trigger", "tlsa_t", "pctp_t", "pfx", "smt_t", "hlsl"));

protectedPackages.addAll(Arrays.asList("patchdata.package", "spore_audio1.package", "spore_audio2.package",
"spore_content.package", "spore_game.package", "spore_graphics.package", "spore_pack_03.package",
Expand Down
2 changes: 2 additions & 0 deletions src/sporemodder/FormatManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import sporemodder.file.prop.PropConverter;
import sporemodder.file.raster.RasterConverter;
import sporemodder.file.rw4.RenderWareConverter;
import sporemodder.file.shaders.SmtConverter;
import sporemodder.file.tlsa.TLSAConverter;

public class FormatManager extends AbstractManager {
Expand All @@ -39,6 +40,7 @@ public class FormatManager extends AbstractManager {

@Override
public void initialize(Properties properties) {
converters.add(new SmtConverter());
converters.add(new RasterConverter());
converters.add(new PCTPConverter());
converters.add(new TLSAConverter());
Expand Down
10 changes: 10 additions & 0 deletions src/sporemodder/MainApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import javafx.application.Application;
import javafx.application.Platform;
import javafx.stage.Stage;
import sporemodder.file.shaders.FXCompiler;

/**
* The main class of the program.
Expand All @@ -48,6 +49,7 @@ public class MainApp extends Application {
private FormatManager formatManager;
private FileManager fileManager;
private UpdateManager updateManager;
private FXCompiler fxCompiler;

private Properties settings;

Expand Down Expand Up @@ -135,6 +137,10 @@ public UpdateManager getUpdateManager() {
return updateManager;
}

public FXCompiler getFXCompiler() {
return fxCompiler;
}

/**
* Returns the current instance of the MainApp class.
*/
Expand All @@ -160,6 +166,7 @@ private void init(boolean testInit) {
formatManager = new FormatManager();
fileManager = new FileManager();
updateManager = new UpdateManager();
fxCompiler = new FXCompiler();

// Initialize it first, otherwise we can't get the settings
pathManager.initialize(null);
Expand All @@ -185,6 +192,7 @@ private void init(boolean testInit) {
projectManager.initialize(settings);
if (!testInit) documentationManager.initialize(settings);
formatManager.initialize(settings);
fxCompiler.initialize(settings);

// The plugin must go last, as plugins will use the other managers
pluginManager.initialize(settings);
Expand All @@ -201,6 +209,7 @@ public void saveSettings() {
documentationManager.saveSettings(settings);
formatManager.saveSettings(settings);
fileManager.saveSettings(settings);
fxCompiler.saveSettings(settings);

try (OutputStream stream = new FileOutputStream(pathManager.getProgramFile("config.properties"))) {
settings.store(stream, null);
Expand All @@ -219,6 +228,7 @@ public void stop() {
// The plugin must go first, as plugins will use the other managers
pluginManager.dispose();

fxCompiler.dispose();
documentationManager.dispose();
formatManager.dispose();
editorManager.dispose();
Expand Down
11 changes: 11 additions & 0 deletions src/sporemodder/ProjectManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -1750,6 +1750,7 @@ private void importFile(File sourceFile, File destFolder) throws IOException {

MemoryStream stream = XmlPropParser.xmlToProp(in);
stream.seek(0);
//stream.writeToFile(new File(destFolder, name + ".prop"));

PropertyList list = new PropertyList();
list.read(stream);
Expand Down Expand Up @@ -1919,6 +1920,7 @@ public boolean importOldProject() {
ImportProjectTask task = new ImportProjectTask(project, sourceFolder, fileRegistry, propRegistry, typeRegistry);
task.showProgressDialog();

hasher.replaceRegistries(null, null, null);
hasher.setUpdateProjectRegistry(false);
saveNamesRegistry(project);
hasher.getProjectRegistry().clear();
Expand Down Expand Up @@ -1978,4 +1980,13 @@ public boolean showSaveDialog() {
return false;
}
}

public static void main(String[] args) throws IOException {
MainApp.testInit();

File file = new File("C:\\Users\\Eric\\Downloads\\DI_ItemDrop.prop.xml");
File destFolder = new File("C:\\Users\\Eric\\Desktop");

ProjectManager.get().importFile(file, destFolder);
}
}
1 change: 1 addition & 0 deletions src/sporemodder/UIManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,7 @@ public boolean tryAction(SimpleAction action, String errorText) {
return true;
}
catch (Exception e) {
e.printStackTrace();
showErrorDialog(e, errorText, true);
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion src/sporemodder/UpdateManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public class UpdateManager {

private static final String GITHUB_URL = "https://api.github.com";

public final VersionInfo versionInfo = new VersionInfo(2, 0, 2, null);
public final VersionInfo versionInfo = new VersionInfo(2, 0, 3, null);

public static UpdateManager get() {
return MainApp.get().getUpdateManager();
Expand Down
19 changes: 8 additions & 11 deletions src/sporemodder/file/dbpf/DBPFPackingTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ public boolean accept(File arg0) {
boolean bUsesConverter = false;

String name = file.getName();
file = getNestedFile(file, name);
file = getNestedFile(file, name, converters);

// Skip if there was a problem
if (file == null) continue;
Expand Down Expand Up @@ -285,20 +285,17 @@ public DBPFItem getTemporaryItem() {
}

//TODO consider changing how nested files work
private File getNestedFile(File file, String name) {
private File getNestedFile(File file, String name, List<Converter> converters) {
if (!file.isFile()) {
if (name.contains(".") && !name.endsWith(".effdir.unpacked")) {
File newFile = new File(file, name);
if (!newFile.exists()) {
failedFiles.put(file, new UnsupportedOperationException("Couldn't find file " + name + " inside subfolder " + name));
return null;
}
file = newFile;
for (Converter converter : converters) {
if (converter.isEncoder(file)) return file;
}
else if (!name.endsWith(".effdir.unpacked")) {
failedFiles.put(file, new UnsupportedOperationException("Nested subfolders are not supported. File: " + name));
File newFile = new File(file, name);
if (!newFile.exists()) {
failedFiles.put(file, new UnsupportedOperationException("Couldn't find file " + name + " inside subfolder " + name));
return null;
}
file = newFile;
}

return file;
Expand Down
28 changes: 17 additions & 11 deletions src/sporemodder/file/effects/EffectDirectory.java
Original file line number Diff line number Diff line change
Expand Up @@ -340,15 +340,18 @@ public void read(StreamReader stream) throws IOException {

componentOffsets[type] = offset + 4;

List<EffectComponent> list = new ArrayList<EffectComponent>(count);
components.set(type, list);

String keyword = factories[type].getKeyword();

for (int i = 0; i < count; ++i) {
EffectComponent component = factories[type].create(this, version);
component.setName(keyword + '-' + Integer.toString(i));
list.add(component);
if (type < factories.length && factories[type] != null &&
version >= factories[type].getMinVersion() && version <= factories[type].getMaxVersion()) {
List<EffectComponent> list = new ArrayList<EffectComponent>(count);
components.set(type, list);

String keyword = factories[type].getKeyword();

for (int i = 0; i < count; ++i) {
EffectComponent component = factories[type].create(this, version);
component.setName(keyword + '-' + Integer.toString(i));
list.add(component);
}
}

stream.seek(offset + size);
Expand Down Expand Up @@ -762,8 +765,11 @@ public static <T> void copyArray(T[] dest, T[] source) {
public static void main(String[] args) throws IOException {
MainApp.testInit();

String path = "E:\\Eric\\Eclipse Projects\\SporeModder FX\\Projects\\Effect Editor\\gameEffects_3~\\games.effdir";
String outputPath = "E:\\Eric\\Eclipse Projects\\SporeModder FX\\Projects\\Effect Editor\\gameEffects_3~\\games.effdir.unpacked";
// String path = "E:\\Eric\\Eclipse Projects\\SporeModder FX\\Projects\\Effect Editor\\gameEffects_3~\\editors.effdir";
// String outputPath = "E:\\Eric\\Eclipse Projects\\SporeModder FX\\Projects\\Effect Editor\\gameEffects_3~\\editors.effdir.unpacked";

String path = "E:\\Eric\\Eclipse Projects\\SporeModder FX\\Projects\\Effects\\gameEffects_3~\\base.effdir";
String outputPath = "E:\\Eric\\Eclipse Projects\\SporeModder FX\\Projects\\Effects\\gameEffects_3~\\base.effdir.unpacked";

long time = System.currentTimeMillis();

Expand Down
8 changes: 6 additions & 2 deletions src/sporemodder/file/effects/LightEffect.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ public LightEffect(EffectDirectory effectDirectory, int version) {

@Override public void read(StreamReader in) throws IOException {

System.out.println(in.getFilePointer());

flags = in.readInt(); // & 0xF ?
type = in.readByte();

Expand Down Expand Up @@ -110,8 +112,10 @@ public LightEffect(EffectDirectory effectDirectory, int version) {
out.writeInt(flags);
out.writeByte(type);

out.writeFloat(life);
out.writeShort(loop);
if (version > 1) {
out.writeFloat(life);
out.writeShort(loop);
}

out.writeInt(color.size());
for (ColorRGB f : color) f.writeLE(out);
Expand Down
Loading

0 comments on commit bc47389

Please sign in to comment.