Merge pull request #90 from toolbox4minecraft/cleaning-up

Cleaning up
master
Stefan Dollase 2016-02-20 04:43:04 +01:00
commit 56a3b3e6b6
7 changed files with 32 additions and 27 deletions

View File

@ -120,7 +120,8 @@ public class Amidst {
return new AmidstSettings(Preferences.userNodeForPackage(Amidst.class));
}
private static void enableGraphicsAccelerationIfNecessary(Setting<Boolean> graphicsAcceleration) {
private static void enableGraphicsAccelerationIfNecessary(
Setting<Boolean> graphicsAcceleration) {
if (graphicsAcceleration.get()) {
Log.i("Graphics Acceleration: enabled");
System.setProperty("sun.java2d.opengl", "True");
@ -130,14 +131,15 @@ public class Amidst {
}
}
private static void startApplication(CommandLineParameters parameters, AmidstMetaData metadata,
AmidstSettings settings) {
SwingUtilities.invokeLater(() -> doStartApplication(parameters, metadata, settings));
private static void startApplication(CommandLineParameters parameters,
AmidstMetaData metadata, AmidstSettings settings) {
SwingUtilities.invokeLater(() -> doStartApplication(parameters,
metadata, settings));
}
@CalledOnlyBy(AmidstThread.EDT)
private static void doStartApplication(CommandLineParameters parameters, AmidstMetaData metadata,
AmidstSettings settings) {
private static void doStartApplication(CommandLineParameters parameters,
AmidstMetaData metadata, AmidstSettings settings) {
try {
new Application(parameters, metadata, settings).run();
} catch (DotMinecraftDirectoryNotFoundException e) {

View File

@ -33,7 +33,8 @@ public class Application {
private volatile MainWindow mainWindow;
@CalledOnlyBy(AmidstThread.EDT)
public Application(CommandLineParameters parameters, AmidstMetaData metadata, AmidstSettings settings)
public Application(CommandLineParameters parameters,
AmidstMetaData metadata, AmidstSettings settings)
throws DotMinecraftDirectoryNotFoundException,
LocalMinecraftInterfaceCreationException {
this.parameters = parameters;

View File

@ -244,11 +244,18 @@ public class Actions {
}
@CalledOnlyBy(AmidstThread.EDT)
public void disabledGraphicsAcceleration() {
mainWindow.displayMessage("Disabled Graphics Acceleration",
"You just disabled the Graphics Acceleration. This will lead to a significant drop in performance.\n"
+ "You need to restart Amidst for the changes to take effect.\n\n"
+ "If you did not mean to do this, you can re-enable the Graphics Acceleration via the Settings menu.");
public void updatedGraphicsAcceleration(boolean isEnabled) {
if (isEnabled) {
Log.i("Graphics Acceleration: enabled");
} else {
Log.i("Graphics Acceleration: disabled");
mainWindow
.displayMessage(
"Disabled Graphics Acceleration",
"You just disabled the Graphics Acceleration. This will lead to a significant drop in performance.\n"
+ "You need to restart Amidst for the changes to take effect.\n\n"
+ "If you did not mean to do this, you can re-enable the Graphics Acceleration via the Settings menu.");
}
}
@CalledOnlyBy(AmidstThread.EDT)

View File

@ -9,7 +9,6 @@ import javax.swing.JMenuItem;
import amidst.AmidstSettings;
import amidst.documentation.NotThreadSafe;
import amidst.gui.main.Actions;
import amidst.logging.Log;
import amidst.mojangapi.world.WorldType;
import amidst.settings.Setting;
import amidst.settings.Settings;
@ -69,7 +68,7 @@ public class AmidstMenuBuilder {
result.setMnemonic(KeyEvent.VK_W);
// @formatter:off
Menus.item(result, actions::goToCoordinate, "Go to Coordinate", KeyEvent.VK_C, "ctrl shift C");
Menus.item(result, actions::goToSpawn, "Go to Spawn", KeyEvent.VK_S, "ctrl shift S");
Menus.item(result, actions::goToSpawn, "Go to World Spawn", KeyEvent.VK_S, "ctrl shift S");
Menus.item(result, actions::goToStronghold, "Go to Stronghold", KeyEvent.VK_H, "ctrl shift H");
Menus.item(result, actions::goToPlayer, "Go to Player", KeyEvent.VK_P, "ctrl shift P");
result.addSeparator();
@ -115,14 +114,9 @@ public class AmidstMenuBuilder {
}
private Setting<Boolean> wrapGraphicsAcceleration() {
return Settings.createWithListener(settings.graphicsAcceleration, () -> {
if (settings.graphicsAcceleration.get()) {
Log.i("Graphics Acceleration: enabled");
} else {
Log.i("Graphics Acceleration: disabled");
actions.disabledGraphicsAcceleration();
}
});
// @formatter:off
return Settings.createWithListener(settings.graphicsAcceleration, () -> actions.updatedGraphicsAcceleration(settings.graphicsAcceleration.get()));
// @formatter:on
}
private JMenu create_Settings_DefaultWorldType() {

View File

@ -130,6 +130,7 @@ public class BiomeProfileMenuFactory {
BiomeProfileVisitorImpl visitor = new BiomeProfileVisitorImpl(
parentMenu, actions);
biomeProfileDirectory.visitProfiles(visitor);
parentMenu.addSeparator();
parentMenu.add(createReloadMenuItem());
visitor.selectFirstProfile();
}

View File

@ -28,7 +28,7 @@ public class Viewer {
@CalledOnlyBy(AmidstThread.EDT)
@Override
public void paint(Graphics g) {
public void paintComponent(Graphics g) {
Graphics2D g2d = (Graphics2D) g.create();
drawer.draw(g2d, getWidth(), getHeight(), getMousePositionOrNull(),
widgetFontMetrics);
@ -47,7 +47,7 @@ public class Viewer {
g2d.dispose();
return result;
}
/**
* The method getMousePosition() might throw a null pointer exception in
* a multi-monitor setup, as soon as the window is dragged to the other
@ -59,7 +59,7 @@ public class Viewer {
return getMousePosition();
} catch (NullPointerException e) {
return null;
}
}
}
}

View File

@ -69,8 +69,8 @@ public class LocalMinecraftInterface implements MinecraftInterface {
public synchronized void createWorld(long seed, WorldType worldType, String generatorOptions)
throws MinecraftInterfaceException {
try {
Log.debug("Attempting to create world with seed: " + seed + ", type: " + worldType.getName() + ", and the following generator options:");
Log.debug(generatorOptions);
Log.i("Creating world with seed '" + seed + "' and type '" + worldType.getName() + "'");
Log.i("Using the following generator options: " + generatorOptions);
initializeBlock();
Object[] genLayers = getGenLayers(seed, worldType, generatorOptions);
quarterResolutionBiomeGenerator = new SymbolicObject(genLayerClass, genLayers[0]);