Skip to content

Commit 6ecdb43

Browse files
committed
initial version
1 parent 81c8dbe commit 6ecdb43

File tree

11 files changed

+953
-0
lines changed

11 files changed

+953
-0
lines changed

pom.xml

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
7+
<groupId>de.zocker160.adk.analyzer</groupId>
8+
<artifactId>BinAnalyzer</artifactId>
9+
<version>1.0</version>
10+
<name>BinAnalyzer</name>
11+
12+
<properties>
13+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
14+
<junit.version>5.8.2</junit.version>
15+
</properties>
16+
17+
<dependencies>
18+
<dependency>
19+
<groupId>org.openjfx</groupId>
20+
<artifactId>javafx-controls</artifactId>
21+
<version>11.0.2</version>
22+
<scope>compile</scope>
23+
</dependency>
24+
<dependency>
25+
<groupId>org.openjfx</groupId>
26+
<artifactId>javafx-fxml</artifactId>
27+
<version>11.0.2</version>
28+
<scope>compile</scope>
29+
</dependency>
30+
31+
<!-- needed to create cross platform JAR file -->
32+
<dependency>
33+
<groupId>org.openjfx</groupId>
34+
<artifactId>javafx-graphics</artifactId>
35+
<version>11.0.2</version>
36+
<classifier>linux</classifier>
37+
<scope>compile</scope>
38+
</dependency>
39+
<dependency>
40+
<groupId>org.openjfx</groupId>
41+
<artifactId>javafx-graphics</artifactId>
42+
<version>11.0.2</version>
43+
<classifier>win</classifier>
44+
<scope>compile</scope>
45+
</dependency>
46+
<dependency>
47+
<groupId>org.openjfx</groupId>
48+
<artifactId>javafx-graphics</artifactId>
49+
<version>11.0.2</version>
50+
<classifier>mac</classifier>
51+
<scope>compile</scope>
52+
</dependency>
53+
<!-- -->
54+
55+
<dependency>
56+
<groupId>com.google.guava</groupId>
57+
<artifactId>guava</artifactId>
58+
<version>31.0.1-jre</version>
59+
</dependency>
60+
61+
<!--
62+
<dependency>
63+
<groupId>org.kordamp.ikonli</groupId>
64+
<artifactId>ikonli-javafx</artifactId>
65+
<version>12.2.0</version>
66+
<scope>compile</scope>
67+
</dependency>
68+
-->
69+
<dependency>
70+
<groupId>org.controlsfx</groupId>
71+
<artifactId>controlsfx</artifactId>
72+
<version>11.1.1</version>
73+
<scope>compile</scope>
74+
</dependency>
75+
76+
</dependencies>
77+
78+
<build>
79+
<plugins>
80+
<plugin>
81+
<groupId>org.apache.maven.plugins</groupId>
82+
<artifactId>maven-compiler-plugin</artifactId>
83+
<version>3.8.1</version>
84+
<configuration>
85+
<source>11</source>
86+
<target>11</target>
87+
</configuration>
88+
</plugin>
89+
<plugin>
90+
<groupId>org.openjfx</groupId>
91+
<artifactId>javafx-maven-plugin</artifactId>
92+
<version>0.0.8</version>
93+
<executions>
94+
<execution>
95+
<!-- Default configuration for running with: mvn clean javafx:run -->
96+
<id>default-cli</id>
97+
<configuration>
98+
<mainClass>
99+
de.zocker160.adk.analyzer.binanalyzer/de.zocker160.adk.analyzer.binanalyzer.MainWindow
100+
</mainClass>
101+
<launcher>app</launcher>
102+
<jlinkZipName>app</jlinkZipName>
103+
<jlinkImageName>app</jlinkImageName>
104+
<noManPages>true</noManPages>
105+
<stripDebug>true</stripDebug>
106+
<noHeaderFiles>true</noHeaderFiles>
107+
</configuration>
108+
</execution>
109+
</executions>
110+
</plugin>
111+
</plugins>
112+
</build>
113+
</project>
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package de.zocker160.adk.analyzer.binanalyzer;
2+
3+
import com.google.common.io.LittleEndianDataInputStream;
4+
import com.google.common.io.LittleEndianDataOutputStream;
5+
import javafx.scene.paint.Color;
6+
7+
import java.io.IOException;
8+
9+
public class ColorUtil {
10+
public static Color parseFromSteam(LittleEndianDataInputStream inputStream) throws IOException {
11+
return Color.color(inputStream.readFloat(), inputStream.readFloat(), inputStream.readFloat());
12+
}
13+
14+
public static void writeToStream(Color color, LittleEndianDataOutputStream outputStream) throws IOException {
15+
outputStream.writeFloat((float) color.getRed());
16+
outputStream.writeFloat((float) color.getGreen());
17+
outputStream.writeFloat((float) color.getBlue());
18+
}
19+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package de.zocker160.adk.analyzer.binanalyzer;
2+
3+
public class Main {
4+
public static void main(String[] args) {
5+
MainWindow.start();
6+
}
7+
}
Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
package de.zocker160.adk.analyzer.binanalyzer;
2+
3+
import de.zocker160.adk.analyzer.binanalyzer.parser.BinFile;
4+
import de.zocker160.adk.analyzer.binanalyzer.parser.FogZone;
5+
import javafx.application.Application;
6+
import javafx.fxml.FXMLLoader;
7+
import javafx.scene.Scene;
8+
import javafx.scene.control.Button;
9+
import javafx.scene.paint.Color;
10+
import javafx.stage.FileChooser;
11+
import javafx.stage.Stage;
12+
13+
import java.awt.*;
14+
import java.io.File;
15+
import java.io.IOException;
16+
17+
public class MainWindow extends Application {
18+
private static Stage stage;
19+
private static MainWindowController controller;
20+
21+
private static BinFile data;
22+
23+
@Override
24+
public void start(Stage stage) throws IOException {
25+
FXMLLoader fxmlLoader = new FXMLLoader(MainWindow.class.getResource("mainWindow.fxml"));
26+
Scene scene = new Scene(fxmlLoader.load());
27+
28+
MainWindow.stage = stage;
29+
MainWindow.controller = fxmlLoader.getController();
30+
31+
stage.setTitle("AdK BIN Editor");
32+
stage.setScene(scene);
33+
stage.show();
34+
}
35+
36+
public static void start() {
37+
launch();
38+
}
39+
40+
public static Stage getStage() {
41+
return stage;
42+
}
43+
44+
public static MainWindowController getController() {
45+
return controller;
46+
}
47+
48+
protected static String openFile() {
49+
var fileChooser = new FileChooser();
50+
fileChooser.setTitle("Select BIN file");
51+
fileChooser.getExtensionFilters().addAll(
52+
new FileChooser.ExtensionFilter("AdK BIN File", "*.bin")
53+
);
54+
55+
File file = fileChooser.showOpenDialog(stage);
56+
57+
BinFile binFile = BinFile.loadFile(file);
58+
data = binFile;
59+
60+
controller.value1.setText(binFile.getValue1());
61+
controller.value2.setText(binFile.getValue2());
62+
controller.value3.setText(binFile.getValue3());
63+
controller.value4.setText(binFile.getValue4());
64+
65+
controller.fogStart.setText(binFile.getFogStart());
66+
controller.fogEnd.setText(binFile.getFogEnd());
67+
68+
controller.fogColor.setValue(binFile.fogColor);
69+
controller.ambientColor.setValue(binFile.ambientColor);
70+
controller.lightColor.setValue(binFile.lightColor);
71+
72+
controller.maxZone = binFile.getNumberOfZones()-1;
73+
controller.setZone(0);
74+
75+
return file.getName();
76+
}
77+
78+
protected static void saveToFile() {
79+
if (data == null) return;
80+
81+
var fileChooser = new FileChooser();
82+
fileChooser.setTitle("Save file...");
83+
fileChooser.getExtensionFilters().addAll(
84+
new FileChooser.ExtensionFilter("AdK BIN file", "*.bin"),
85+
new FileChooser.ExtensionFilter("All files", "*.*")
86+
);
87+
88+
File file = fileChooser.showSaveDialog(stage);
89+
90+
// global settings
91+
BinFile binFile = data;
92+
93+
binFile.setValue1(controller.value1.getText());
94+
binFile.setValue2(controller.value2.getText());
95+
binFile.setValue3(controller.value3.getText());
96+
binFile.setValue4(controller.value4.getText());
97+
98+
binFile.setFogStart(controller.fogStart.getText());
99+
binFile.setFogEnd(controller.fogEnd.getText());
100+
101+
binFile.fogColor = controller.fogColor.getValue();
102+
binFile.ambientColor = controller.ambientColor.getValue();
103+
binFile.lightColor = controller.lightColor.getValue();
104+
105+
// current zone
106+
saveZone(controller.getCurrentZone());
107+
108+
data.save(file);
109+
}
110+
111+
protected static void loadZone(int zone) {
112+
if (data == null) return;
113+
114+
FogZone fogZone = data.getZone(zone);
115+
116+
controller.fogColorZone.setValue(fogZone.getFogColor());
117+
controller.ambientColorZone.setValue(fogZone.getAmbientColor());
118+
controller.lightColorZone.setValue(fogZone.getLightColor());
119+
120+
controller.shadowDensityZone.setText(fogZone.getShadowDensity());
121+
122+
controller.fogStartZone.setText(fogZone.getFogStart());
123+
controller.fogEndZone.setText(fogZone.getFogEnd());
124+
125+
controller.posXZone.setText(fogZone.getPostition().xStr());
126+
controller.posYZone.setText(fogZone.getPostition().yStr());
127+
128+
controller.radiusStartZone.setText(fogZone.getRadiusStart());
129+
controller.radiusEndZone.setText(fogZone.getRadiusEnd());
130+
}
131+
132+
protected static void saveZone(int zone) {
133+
if (data == null) return;
134+
135+
FogZone fogZone = data.getZone(zone);
136+
137+
fogZone.setFogColor(controller.fogColorZone.getValue());
138+
fogZone.setAmbientColor(controller.ambientColor.getValue());
139+
fogZone.setLightColor(controller.lightColor.getValue());
140+
141+
fogZone.setShadowDensity(controller.shadowDensityZone.getText());
142+
143+
fogZone.setFogStart(controller.fogStartZone.getText());
144+
fogZone.setFogEnd(controller.fogEndZone.getText());
145+
146+
fogZone.getPostition().setX(controller.posXZone.getText());
147+
fogZone.getPostition().setY(controller.posYZone.getText());
148+
149+
fogZone.setRadiusStart(controller.radiusStartZone.getText());
150+
fogZone.setRadiusEnd(controller.radiusEndZone.getText());
151+
}
152+
}

0 commit comments

Comments
 (0)