kopia lustrzana https://github.com/jameshball/osci-render
Retain current frame source in project, show helpful error when trying to open .osci file from wrong place, correctly open a folder containing lua files
rodzic
0618b01a95
commit
c6c036e7a0
|
@ -84,7 +84,7 @@ public class GeneralController implements Initializable, SubController {
|
|||
|
||||
new Thread(() -> {
|
||||
try {
|
||||
mainController.updateFiles(files, names);
|
||||
mainController.updateFiles(files, names, 0);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
|
|
@ -647,7 +647,7 @@ public class MainController implements Initializable, FrequencyListener, MidiLis
|
|||
objTitledPane.setDisable(!ObjParser.isObjFile(frameSourcePaths.get(index)));
|
||||
}
|
||||
|
||||
void updateFiles(List<byte[]> files, List<String> names) throws Exception {
|
||||
void updateFiles(List<byte[]> files, List<String> names, int startingFrameSource) throws Exception {
|
||||
List<FrameSource<Vector2>> newSampleSources = new ArrayList<>();
|
||||
List<FrameSource<List<Shape>>> newFrameSources = new ArrayList<>();
|
||||
List<String> newFrameSourcePaths = new ArrayList<>();
|
||||
|
@ -661,11 +661,11 @@ public class MainController implements Initializable, FrequencyListener, MidiLis
|
|||
for (int i = 0; i < files.size(); i++) {
|
||||
try {
|
||||
if (LuaParser.isLuaFile(names.get(i))) {
|
||||
newFrameSources.add(null);
|
||||
newSampleSources.add(new LuaParser(new ByteArrayInputStream(files.get(i))).parse());
|
||||
newFrameSources.add(null);
|
||||
} else {
|
||||
newSampleSources.add(null);
|
||||
newFrameSources.add(ParserFactory.getParser(names.get(i), files.get(i)).parse());
|
||||
newSampleSources.add(null);
|
||||
}
|
||||
newFrameSourcePaths.add(names.get(i));
|
||||
newOpenFiles.add(files.get(i));
|
||||
|
@ -689,7 +689,7 @@ public class MainController implements Initializable, FrequencyListener, MidiLis
|
|||
frameSources = newFrameSources;
|
||||
frameSourcePaths = newFrameSourcePaths;
|
||||
openFiles = newOpenFiles;
|
||||
changeFrameSource(0);
|
||||
changeFrameSource(startingFrameSource);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -1014,6 +1014,10 @@ public class MainController implements Initializable, FrequencyListener, MidiLis
|
|||
}
|
||||
root.appendChild(filesElement);
|
||||
|
||||
Element frameSource = document.createElement("frameSource");
|
||||
frameSource.appendChild(document.createTextNode(String.valueOf(currentFrameSource)));
|
||||
root.appendChild(frameSource);
|
||||
|
||||
TransformerFactory transformerFactory = TransformerFactory.newInstance();
|
||||
Transformer transformer = transformerFactory.newTransformer();
|
||||
DOMSource domSource = new DOMSource(document);
|
||||
|
@ -1129,7 +1133,14 @@ public class MainController implements Initializable, FrequencyListener, MidiLis
|
|||
String fileName = fileElement.getElementsByTagName("name").item(0).getTextContent();
|
||||
fileNames.add(fileName);
|
||||
}
|
||||
updateFiles(files, fileNames);
|
||||
|
||||
Element frameSource = (Element) root.getElementsByTagName("frameSource").item(0);
|
||||
if (frameSource != null) {
|
||||
updateFiles(files, fileNames, Integer.parseInt(frameSource.getTextContent()));
|
||||
} else {
|
||||
updateFiles(files, fileNames, 0);
|
||||
}
|
||||
|
||||
openProjectPath = projectFileName;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
|
|
@ -22,6 +22,8 @@ public class ParserFactory {
|
|||
return new SvgParser(bais);
|
||||
} else if (TextParser.isTxtFile(filePath)) {
|
||||
return new TextParser(bais);
|
||||
} else if (filePath.matches(".*\\.osci")) {
|
||||
throw new IOException(".osci project files should be opened using File > Open Project");
|
||||
}
|
||||
throw new IOException("Can't parse " + new File(filePath).getName());
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
<AnchorPane id="control-pane" prefHeight="324.0" prefWidth="364.0" xmlns="http://javafx.com/javafx/17" xmlns:fx="http://javafx.com/fxml/1" fx:controller="sh.ball.gui.controller.GeneralController">
|
||||
<children>
|
||||
<Button fx:id="chooseFileButton" layoutX="14.0" layoutY="26.0" mnemonicParsing="false" prefHeight="26.0" prefWidth="114.0" text="Choose File" />
|
||||
<Label fx:id="fileLabel" layoutX="143.0" layoutY="30.0" maxWidth="270.0" prefHeight="18.0" prefWidth="210.0" text="cube.obj" />
|
||||
<Label fx:id="fileLabel" alignment="TOP_LEFT" layoutX="143.0" layoutY="30.0" maxWidth="270.0" prefHeight="42.0" prefWidth="210.0" text="cube.obj" wrapText="true" />
|
||||
<Label fx:id="recordLabel" layoutX="13.0" layoutY="304.0" maxWidth="451.0" prefHeight="18.0" prefWidth="343.0" />
|
||||
<Label id="frequency" fx:id="frequencyLabel" layoutX="14.0" layoutY="141.0" prefHeight="58.0" prefWidth="343.0" text="L/R Frequency: " />
|
||||
<Button fx:id="chooseFolderButton" layoutX="14.0" layoutY="76.0" mnemonicParsing="false" prefHeight="26.0" prefWidth="114.0" text="Choose Folder" />
|
||||
|
|
Ładowanie…
Reference in New Issue