Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port to Lorenz for mappings IO #35

Open
wants to merge 7 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,21 @@ project('FernFlower') {
// Project repositories
repositories {
mavenCentral()
maven {
url 'https://oss.sonatype.org/content/groups/public/'
}
}

// Project dependencies
dependencies {
compile 'com.google.guava:guava:19.0'

// Mapping IO (Lorenz)
compile 'org.cadixdev:lorenz:0.5.0-SNAPSHOT'
compile 'org.cadixdev:lorenz-io-enigma:0.5.0-SNAPSHOT'
compile 'org.cadixdev:lorenz-io-jam:0.5.0-SNAPSHOT'
compile 'org.cadixdev:lorenz-io-kin:0.5.0-SNAPSHOT'

compile project('FernFlower')

testCompile 'junit:junit:4.12'
Expand Down Expand Up @@ -88,6 +98,8 @@ shadowJar {

// License header formatting
license {
exclude '**/blue/lapis/nocturne/gui/io/MappingsDialogHelper.java'
exclude '**/blue/lapis/nocturne/gui/tree/*.java'
include '**/*.java'
include '**/*.css'
include '**/*.fxml'
Expand Down
44 changes: 7 additions & 37 deletions src/main/java/blue/lapis/nocturne/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,11 @@

package blue.lapis.nocturne;

import blue.lapis.nocturne.gui.io.mappings.MappingsSaveDialogHelper;
import blue.lapis.nocturne.gui.scene.control.WebLink;
import blue.lapis.nocturne.jar.model.ClassSet;
import blue.lapis.nocturne.mapping.MappingContext;
import blue.lapis.nocturne.mapping.MappingFormat;
import blue.lapis.nocturne.util.helper.PropertiesHelper;
import blue.lapis.nocturne.util.helper.SceneHelper;
import javafx.application.Application;
import javafx.event.EventHandler;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
Expand All @@ -45,13 +41,12 @@
import javafx.scene.text.Text;
import javafx.scene.text.TextFlow;
import javafx.stage.Stage;
import javafx.stage.WindowEvent;
import org.cadixdev.lorenz.MappingSet;

import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.nio.file.Path;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
import java.util.logging.ConsoleHandler;
Expand All @@ -63,16 +58,6 @@ public class Main extends Application {

private static Main instance;

private static final EventHandler<WindowEvent> CLOSE_HANDLER = event -> {
try {
if (MappingsSaveDialogHelper.doDirtyConfirmation()) {
event.consume();
}
} catch (IOException ex) {
throw new RuntimeException(ex);
}
};

private static final Logger LOGGER = Logger.getLogger("Nocturne");
private static final Logger FERNFLOWER_LOGGER = Logger.getLogger("FernFlower");

Expand All @@ -84,9 +69,7 @@ public class Main extends Application {
private Stage mainStage;
private Scene scene;

private final MappingContext mappingContext = new MappingContext();
private Path currentMappingsPath;
private MappingFormat currentMappingFormat;
private MappingSet mappings = MappingSet.create();
private ClassSet loadedJar;

static {
Expand Down Expand Up @@ -214,7 +197,6 @@ public void loadView(String lang) throws IOException {
SceneHelper.addStdStylesheet(scene);
mainStage.setTitle("Nocturne");
mainStage.setScene(scene);
mainStage.setOnCloseRequest(CLOSE_HANDLER);
mainStage.show();
} else {
scene.setRoot(root);
Expand All @@ -237,24 +219,12 @@ public static Stage getMainStage() {
return getInstance().mainStage;
}

public static MappingContext getMappingContext() {
return getInstance().mappingContext;
}

public static Path getCurrentMappingsPath() {
return getInstance().currentMappingsPath;
}

public static void setCurrentMappingsPath(Path path) {
getInstance().currentMappingsPath = path;
}

public static MappingFormat getCurrentMappingFormat() {
return getInstance().currentMappingFormat;
public static MappingSet getMappings() {
return getInstance().mappings;
}

public static void setCurrentMappingFormat(MappingFormat currentWriterType) {
getInstance().currentMappingFormat = currentWriterType;
public static void clearMappings() {
getInstance().mappings = MappingSet.create();
}

public static ClassSet getLoadedJar() {
Expand All @@ -275,7 +245,7 @@ public static void updateTitle() {
if (getLoadedJar() == null) {
title = "Nocturne";
} else {
title = "Nocturne - " + (getMappingContext().isDirty() ? "*" : "") + getLoadedJar().getName();
title = "Nocturne - " + getLoadedJar().getName();
}

if (!getMainStage().getTitle().equals(title)) {
Expand Down
Loading