replaced all occurrences: biome color profile -> biome profile

This enables us to store more biome related information in the profiles in the future.

I also changed the default biome profiles directory name back to 'biome' to keep backwards compatibility with Amidst v3.7.
master
Stefan Dollase 2016-02-15 19:40:17 +01:00
parent b613946ff2
commit a9dfdf184d
20 changed files with 110 additions and 116 deletions

View File

@ -9,8 +9,8 @@ import amidst.mojangapi.world.Dimension;
import amidst.mojangapi.world.WorldType; import amidst.mojangapi.world.WorldType;
import amidst.settings.Setting; import amidst.settings.Setting;
import amidst.settings.Settings; import amidst.settings.Settings;
import amidst.settings.biomecolorprofile.BiomeColorProfile; import amidst.settings.biomeprofile.BiomeProfile;
import amidst.settings.biomecolorprofile.BiomeColorProfileSelection; import amidst.settings.biomeprofile.BiomeProfileSelection;
@ThreadSafe @ThreadSafe
public class AmidstSettings { public class AmidstSettings {
@ -41,7 +41,7 @@ public class AmidstSettings {
/** /**
* This is not persisted. * This is not persisted.
*/ */
public final BiomeColorProfileSelection biomeColorProfileSelection; public final BiomeProfileSelection biomeProfileSelection;
@CalledOnlyBy(AmidstThread.EDT) @CalledOnlyBy(AmidstThread.EDT)
public AmidstSettings(Preferences preferences) { public AmidstSettings(Preferences preferences) {
@ -69,7 +69,7 @@ public class AmidstSettings {
lastProfile = Settings.createString( preferences, "profile", ""); lastProfile = Settings.createString( preferences, "profile", "");
worldType = Settings.createString( preferences, "worldType", WorldType.PROMPT_EACH_TIME); worldType = Settings.createString( preferences, "worldType", WorldType.PROMPT_EACH_TIME);
biomeColorProfileSelection = new BiomeColorProfileSelection(BiomeColorProfile.getDefaultProfile()); biomeProfileSelection = new BiomeProfileSelection(BiomeProfile.getDefaultProfile());
// @formatter:on // @formatter:on
} }
} }

View File

@ -18,7 +18,7 @@ import amidst.mojangapi.minecraftinterface.local.LocalMinecraftInterfaceCreation
import amidst.mojangapi.world.SeedHistoryLogger; import amidst.mojangapi.world.SeedHistoryLogger;
import amidst.mojangapi.world.WorldBuilder; import amidst.mojangapi.world.WorldBuilder;
import amidst.mojangapi.world.player.PlayerInformationCacheImpl; import amidst.mojangapi.world.player.PlayerInformationCacheImpl;
import amidst.settings.biomecolorprofile.BiomeColorProfileDirectory; import amidst.settings.biomeprofile.BiomeProfileDirectory;
import amidst.threading.ThreadMaster; import amidst.threading.ThreadMaster;
@NotThreadSafe @NotThreadSafe
@ -27,7 +27,7 @@ public class Application {
private final AmidstMetaData metadata; private final AmidstMetaData metadata;
private final AmidstSettings settings; private final AmidstSettings settings;
private final MojangApi mojangApi; private final MojangApi mojangApi;
private final BiomeColorProfileDirectory biomeColorProfileDirectory; private final BiomeProfileDirectory biomeProfileDirectory;
private final ViewerFacadeBuilder viewerFacadeBuilder; private final ViewerFacadeBuilder viewerFacadeBuilder;
private final ThreadMaster threadMaster; private final ThreadMaster threadMaster;
@ -42,7 +42,7 @@ public class Application {
this.metadata = metadata; this.metadata = metadata;
this.settings = createSettings(); this.settings = createSettings();
this.mojangApi = createMojangApi(); this.mojangApi = createMojangApi();
this.biomeColorProfileDirectory = createBiomeColorProfileDirectory(); this.biomeProfileDirectory = createBiomeProfileDirectory();
this.viewerFacadeBuilder = createViewerFacadeBuilder(); this.viewerFacadeBuilder = createViewerFacadeBuilder();
this.threadMaster = createThreadMaster(); this.threadMaster = createThreadMaster();
} }
@ -63,9 +63,8 @@ public class Application {
} }
@CalledOnlyBy(AmidstThread.EDT) @CalledOnlyBy(AmidstThread.EDT)
private BiomeColorProfileDirectory createBiomeColorProfileDirectory() { private BiomeProfileDirectory createBiomeProfileDirectory() {
return BiomeColorProfileDirectory return BiomeProfileDirectory.create(parameters.biomeProfilesDirectory);
.create(parameters.biomeColorProfilesDirectory);
} }
@CalledOnlyBy(AmidstThread.EDT) @CalledOnlyBy(AmidstThread.EDT)
@ -103,7 +102,7 @@ public class Application {
@CalledOnlyBy(AmidstThread.EDT) @CalledOnlyBy(AmidstThread.EDT)
public void displayMainWindow() { public void displayMainWindow() {
setMainWindow(new MainWindow(this, metadata, settings, mojangApi, setMainWindow(new MainWindow(this, metadata, settings, mojangApi,
biomeColorProfileDirectory, viewerFacadeBuilder, threadMaster)); biomeProfileDirectory, viewerFacadeBuilder, threadMaster));
setProfileSelectWindow(null); setProfileSelectWindow(null);
} }

View File

@ -23,8 +23,8 @@ public class CommandLineParameters {
@Option(name = "-mcjson", usage = "location of the minecraft json file", metaVar = "<file>", depends = { "-mcjar" }) @Option(name = "-mcjson", usage = "location of the minecraft json file", metaVar = "<file>", depends = { "-mcjar" })
public volatile String minecraftJsonFile; public volatile String minecraftJsonFile;
@Option(name = "-biome-color-profiles", usage = "location of the biome color profile directory", metaVar = "<directory>") @Option(name = "-biome-profiles", usage = "location of the biome profile directory", metaVar = "<directory>")
public volatile String biomeColorProfilesDirectory; public volatile String biomeProfilesDirectory;
@Option(name = "-history", usage = "location of the seed history file", metaVar = "<file>") @Option(name = "-history", usage = "location of the seed history file", metaVar = "<file>")
public volatile String historyFile; public volatile String historyFile;

View File

@ -5,17 +5,17 @@ import amidst.fragment.Fragment;
import amidst.gui.main.viewer.BiomeSelection; import amidst.gui.main.viewer.BiomeSelection;
import amidst.mojangapi.world.Dimension; import amidst.mojangapi.world.Dimension;
import amidst.mojangapi.world.biome.BiomeColor; import amidst.mojangapi.world.biome.BiomeColor;
import amidst.settings.biomecolorprofile.BiomeColorProfileSelection; import amidst.settings.biomeprofile.BiomeProfileSelection;
@ThreadSafe @ThreadSafe
public class BiomeColorProvider implements ColorProvider { public class BiomeColorProvider implements ColorProvider {
private final BiomeSelection biomeSelection; private final BiomeSelection biomeSelection;
private final BiomeColorProfileSelection biomeColorProfileSelection; private final BiomeProfileSelection biomeProfileSelection;
public BiomeColorProvider(BiomeSelection biomeSelection, public BiomeColorProvider(BiomeSelection biomeSelection,
BiomeColorProfileSelection biomeColorProfileSelection) { BiomeProfileSelection biomeProfileSelection) {
this.biomeSelection = biomeSelection; this.biomeSelection = biomeSelection;
this.biomeColorProfileSelection = biomeColorProfileSelection; this.biomeProfileSelection = biomeProfileSelection;
} }
@Override @Override
@ -33,6 +33,6 @@ public class BiomeColorProvider implements ColorProvider {
} }
private BiomeColor getBiomeColor(int biomeIndex) { private BiomeColor getBiomeColor(int biomeIndex) {
return biomeColorProfileSelection.getBiomeColorOrUnknown(biomeIndex); return biomeProfileSelection.getBiomeColorOrUnknown(biomeIndex);
} }
} }

View File

@ -124,7 +124,7 @@ public class LayerBuilder {
new AlphaInitializer( declarations.get(LayerIds.ALPHA), settings.fragmentFading), new AlphaInitializer( declarations.get(LayerIds.ALPHA), settings.fragmentFading),
new BiomeDataLoader( declarations.get(LayerIds.BIOME_DATA), world.getBiomeDataOracle()), new BiomeDataLoader( declarations.get(LayerIds.BIOME_DATA), world.getBiomeDataOracle()),
new EndIslandsLoader( declarations.get(LayerIds.END_ISLANDS), world.getEndIslandOracle()), new EndIslandsLoader( declarations.get(LayerIds.END_ISLANDS), world.getEndIslandOracle()),
new ImageLoader( declarations.get(LayerIds.BACKGROUND), Resolution.QUARTER, new BackgroundColorProvider(new BiomeColorProvider(biomeSelection, settings.biomeColorProfileSelection), new TheEndColorProvider())), new ImageLoader( declarations.get(LayerIds.BACKGROUND), Resolution.QUARTER, new BackgroundColorProvider(new BiomeColorProvider(biomeSelection, settings.biomeProfileSelection), new TheEndColorProvider())),
new ImageLoader( declarations.get(LayerIds.SLIME), Resolution.CHUNK, new SlimeColorProvider(world.getSlimeChunkOracle())), new ImageLoader( declarations.get(LayerIds.SLIME), Resolution.CHUNK, new SlimeColorProvider(world.getSlimeChunkOracle())),
new WorldIconLoader<Void>( declarations.get(LayerIds.SPAWN), world.getSpawnProducer()), new WorldIconLoader<Void>( declarations.get(LayerIds.SPAWN), world.getSpawnProducer()),
new WorldIconLoader<Void>( declarations.get(LayerIds.STRONGHOLD), world.getStrongholdProducer()), new WorldIconLoader<Void>( declarations.get(LayerIds.STRONGHOLD), world.getStrongholdProducer()),

View File

@ -28,8 +28,8 @@ import amidst.mojangapi.world.coordinates.CoordinatesInWorld;
import amidst.mojangapi.world.icon.WorldIcon; import amidst.mojangapi.world.icon.WorldIcon;
import amidst.mojangapi.world.player.Player; import amidst.mojangapi.world.player.Player;
import amidst.mojangapi.world.player.PlayerCoordinates; import amidst.mojangapi.world.player.PlayerCoordinates;
import amidst.settings.biomecolorprofile.BiomeColorProfile; import amidst.settings.biomeprofile.BiomeProfile;
import amidst.settings.biomecolorprofile.BiomeColorProfileSelection; import amidst.settings.biomeprofile.BiomeProfileSelection;
import amidst.threading.WorkerExecutor; import amidst.threading.WorkerExecutor;
@NotThreadSafe @NotThreadSafe
@ -38,19 +38,19 @@ public class Actions {
private final MojangApi mojangApi; private final MojangApi mojangApi;
private final MainWindow mainWindow; private final MainWindow mainWindow;
private final AtomicReference<ViewerFacade> viewerFacade; private final AtomicReference<ViewerFacade> viewerFacade;
private final BiomeColorProfileSelection biomeColorProfileSelection; private final BiomeProfileSelection biomeProfileSelection;
private final WorkerExecutor workerExecutor; private final WorkerExecutor workerExecutor;
@CalledOnlyBy(AmidstThread.EDT) @CalledOnlyBy(AmidstThread.EDT)
public Actions(Application application, MojangApi mojangApi, public Actions(Application application, MojangApi mojangApi,
MainWindow mainWindow, AtomicReference<ViewerFacade> viewerFacade, MainWindow mainWindow, AtomicReference<ViewerFacade> viewerFacade,
BiomeColorProfileSelection biomeColorProfileSelection, BiomeProfileSelection biomeProfileSelection,
WorkerExecutor workerExecutor) { WorkerExecutor workerExecutor) {
this.application = application; this.application = application;
this.mojangApi = mojangApi; this.mojangApi = mojangApi;
this.mainWindow = mainWindow; this.mainWindow = mainWindow;
this.viewerFacade = viewerFacade; this.viewerFacade = viewerFacade;
this.biomeColorProfileSelection = biomeColorProfileSelection; this.biomeProfileSelection = biomeProfileSelection;
this.workerExecutor = workerExecutor; this.workerExecutor = workerExecutor;
} }
@ -224,8 +224,8 @@ public class Actions {
} }
@CalledOnlyBy(AmidstThread.EDT) @CalledOnlyBy(AmidstThread.EDT)
public void selectBiomeColorProfile(BiomeColorProfile profile) { public void selectBiomeProfile(BiomeProfile profile) {
biomeColorProfileSelection.set(profile); biomeProfileSelection.set(profile);
ViewerFacade viewerFacade = this.viewerFacade.get(); ViewerFacade viewerFacade = this.viewerFacade.get();
if (viewerFacade != null) { if (viewerFacade != null) {
viewerFacade.reloadBackgroundLayer(); viewerFacade.reloadBackgroundLayer();

View File

@ -32,7 +32,7 @@ import amidst.mojangapi.world.WorldSeed;
import amidst.mojangapi.world.WorldType; import amidst.mojangapi.world.WorldType;
import amidst.mojangapi.world.player.MovablePlayerList; import amidst.mojangapi.world.player.MovablePlayerList;
import amidst.mojangapi.world.player.WorldPlayerType; import amidst.mojangapi.world.player.WorldPlayerType;
import amidst.settings.biomecolorprofile.BiomeColorProfileDirectory; import amidst.settings.biomeprofile.BiomeProfileDirectory;
import amidst.threading.ThreadMaster; import amidst.threading.ThreadMaster;
@NotThreadSafe @NotThreadSafe
@ -41,7 +41,7 @@ public class MainWindow {
private final AmidstMetaData metadata; private final AmidstMetaData metadata;
private final AmidstSettings settings; private final AmidstSettings settings;
private final MojangApi mojangApi; private final MojangApi mojangApi;
private final BiomeColorProfileDirectory biomeColorProfileDirectory; private final BiomeProfileDirectory biomeProfileDirectory;
private final ViewerFacadeBuilder viewerFacadeBuilder; private final ViewerFacadeBuilder viewerFacadeBuilder;
private final ThreadMaster threadMaster; private final ThreadMaster threadMaster;
@ -55,13 +55,13 @@ public class MainWindow {
@CalledOnlyBy(AmidstThread.EDT) @CalledOnlyBy(AmidstThread.EDT)
public MainWindow(Application application, AmidstMetaData metadata, public MainWindow(Application application, AmidstMetaData metadata,
AmidstSettings settings, MojangApi mojangApi, AmidstSettings settings, MojangApi mojangApi,
BiomeColorProfileDirectory biomeColorProfileDirectory, BiomeProfileDirectory biomeProfileDirectory,
ViewerFacadeBuilder viewerFacadeBuilder, ThreadMaster threadMaster) { ViewerFacadeBuilder viewerFacadeBuilder, ThreadMaster threadMaster) {
this.application = application; this.application = application;
this.metadata = metadata; this.metadata = metadata;
this.settings = settings; this.settings = settings;
this.mojangApi = mojangApi; this.mojangApi = mojangApi;
this.biomeColorProfileDirectory = biomeColorProfileDirectory; this.biomeProfileDirectory = biomeProfileDirectory;
this.viewerFacadeBuilder = viewerFacadeBuilder; this.viewerFacadeBuilder = viewerFacadeBuilder;
this.threadMaster = threadMaster; this.threadMaster = threadMaster;
this.frame = createFrame(); this.frame = createFrame();
@ -104,14 +104,14 @@ public class MainWindow {
@CalledOnlyBy(AmidstThread.EDT) @CalledOnlyBy(AmidstThread.EDT)
private Actions createActions() { private Actions createActions() {
return new Actions(application, mojangApi, this, viewerFacade, return new Actions(application, mojangApi, this, viewerFacade,
settings.biomeColorProfileSelection, settings.biomeProfileSelection,
threadMaster.getWorkerExecutor()); threadMaster.getWorkerExecutor());
} }
@CalledOnlyBy(AmidstThread.EDT) @CalledOnlyBy(AmidstThread.EDT)
private AmidstMenu createMenuBar() { private AmidstMenu createMenuBar() {
AmidstMenu menuBar = new AmidstMenuBuilder(settings, actions, AmidstMenu menuBar = new AmidstMenuBuilder(settings, actions,
biomeColorProfileDirectory).construct(); biomeProfileDirectory).construct();
frame.setJMenuBar(menuBar.getMenuBar()); frame.setJMenuBar(menuBar.getMenuBar());
return menuBar; return menuBar;
} }

View File

@ -10,13 +10,13 @@ import amidst.AmidstSettings;
import amidst.documentation.NotThreadSafe; import amidst.documentation.NotThreadSafe;
import amidst.gui.main.Actions; import amidst.gui.main.Actions;
import amidst.mojangapi.world.WorldType; import amidst.mojangapi.world.WorldType;
import amidst.settings.biomecolorprofile.BiomeColorProfileDirectory; import amidst.settings.biomeprofile.BiomeProfileDirectory;
@NotThreadSafe @NotThreadSafe
public class AmidstMenuBuilder { public class AmidstMenuBuilder {
private final AmidstSettings settings; private final AmidstSettings settings;
private final Actions actions; private final Actions actions;
private final BiomeColorProfileDirectory biomeColorProfileDirectory; private final BiomeProfileDirectory biomeProfileDirectory;
private final JMenuBar menuBar; private final JMenuBar menuBar;
private JMenu worldMenu; private JMenu worldMenu;
private JMenuItem savePlayerLocationsMenu; private JMenuItem savePlayerLocationsMenu;
@ -24,10 +24,10 @@ public class AmidstMenuBuilder {
private LayersMenu layersMenu; private LayersMenu layersMenu;
public AmidstMenuBuilder(AmidstSettings settings, Actions actions, public AmidstMenuBuilder(AmidstSettings settings, Actions actions,
BiomeColorProfileDirectory biomeColorProfileDirectory) { BiomeProfileDirectory biomeProfileDirectory) {
this.settings = settings; this.settings = settings;
this.actions = actions; this.actions = actions;
this.biomeColorProfileDirectory = biomeColorProfileDirectory; this.biomeProfileDirectory = biomeProfileDirectory;
this.menuBar = createMenuBar(); this.menuBar = createMenuBar();
} }
@ -95,8 +95,8 @@ public class AmidstMenuBuilder {
JMenu result = new JMenu("Settings"); JMenu result = new JMenu("Settings");
result.setMnemonic(KeyEvent.VK_S); result.setMnemonic(KeyEvent.VK_S);
result.add(create_Settings_DefaultWorldType()); result.add(create_Settings_DefaultWorldType());
if (biomeColorProfileDirectory.isValid()) { if (biomeProfileDirectory.isValid()) {
result.add(create_Settings_BiomeColor()); result.add(create_Settings_BiomeProfile());
} }
result.addSeparator(); result.addSeparator();
// @formatter:off // @formatter:off
@ -118,9 +118,9 @@ public class AmidstMenuBuilder {
return result; return result;
} }
private JMenu create_Settings_BiomeColor() { private JMenu create_Settings_BiomeProfile() {
JMenu result = new JMenu("Biome color profile"); JMenu result = new JMenu("Biome profile");
new BiomeColorMenuFactory(result, actions, biomeColorProfileDirectory); new BiomeProfileMenuFactory(result, actions, biomeProfileDirectory);
return result; return result;
} }

View File

@ -15,15 +15,14 @@ import javax.swing.KeyStroke;
import amidst.documentation.NotThreadSafe; import amidst.documentation.NotThreadSafe;
import amidst.gui.main.Actions; import amidst.gui.main.Actions;
import amidst.logging.Log; import amidst.logging.Log;
import amidst.settings.biomecolorprofile.BiomeColorProfile; import amidst.settings.biomeprofile.BiomeProfile;
import amidst.settings.biomecolorprofile.BiomeColorProfileDirectory; import amidst.settings.biomeprofile.BiomeProfileDirectory;
import amidst.settings.biomecolorprofile.BiomeColorProfileVisitor; import amidst.settings.biomeprofile.BiomeProfileVisitor;
@NotThreadSafe @NotThreadSafe
public class BiomeColorMenuFactory { public class BiomeProfileMenuFactory {
@NotThreadSafe @NotThreadSafe
private static class BiomeColorProfileVisitorImpl implements private static class BiomeProfileVisitorImpl implements BiomeProfileVisitor {
BiomeColorProfileVisitor {
private final List<JCheckBoxMenuItem> allCheckBoxes = new ArrayList<JCheckBoxMenuItem>(); private final List<JCheckBoxMenuItem> allCheckBoxes = new ArrayList<JCheckBoxMenuItem>();
private final List<JMenu> menuStack = new ArrayList<JMenu>(); private final List<JMenu> menuStack = new ArrayList<JMenu>();
private ActionListener firstListener; private ActionListener firstListener;
@ -31,7 +30,7 @@ public class BiomeColorMenuFactory {
private final Actions actions; private final Actions actions;
private BiomeColorProfileVisitorImpl(JMenu parentMenu, Actions actions) { private BiomeProfileVisitorImpl(JMenu parentMenu, Actions actions) {
this.actions = actions; this.actions = actions;
menuStack.add(parentMenu); menuStack.add(parentMenu);
} }
@ -48,7 +47,7 @@ public class BiomeColorMenuFactory {
} }
@Override @Override
public void visitProfile(BiomeColorProfile profile) { public void visitProfile(BiomeProfile profile) {
JCheckBoxMenuItem checkBox = createCheckBox(profile); JCheckBoxMenuItem checkBox = createCheckBox(profile);
allCheckBoxes.add(checkBox); allCheckBoxes.add(checkBox);
getLastMenu().add(checkBox); getLastMenu().add(checkBox);
@ -67,7 +66,7 @@ public class BiomeColorMenuFactory {
menuStack.remove(menuStack.size() - 1); menuStack.remove(menuStack.size() - 1);
} }
private JCheckBoxMenuItem createCheckBox(BiomeColorProfile profile) { private JCheckBoxMenuItem createCheckBox(BiomeProfile profile) {
JCheckBoxMenuItem result = new JCheckBoxMenuItem(profile.getName()); JCheckBoxMenuItem result = new JCheckBoxMenuItem(profile.getName());
tryCreateKeyboardShortcut(profile.getShortcut(), result); tryCreateKeyboardShortcut(profile.getShortcut(), result);
result.addActionListener(createListener(profile, result)); result.addActionListener(createListener(profile, result));
@ -87,7 +86,7 @@ public class BiomeColorMenuFactory {
} }
} }
private ActionListener createListener(final BiomeColorProfile profile, private ActionListener createListener(final BiomeProfile profile,
final JCheckBoxMenuItem selectedCheckBox) { final JCheckBoxMenuItem selectedCheckBox) {
ActionListener result = new ActionListener() { ActionListener result = new ActionListener() {
@Override @Override
@ -96,7 +95,7 @@ public class BiomeColorMenuFactory {
checkBox.setSelected(false); checkBox.setSelected(false);
} }
selectedCheckBox.setSelected(true); selectedCheckBox.setSelected(true);
actions.selectBiomeColorProfile(profile); actions.selectBiomeProfile(profile);
} }
}; };
if (firstListener == null) { if (firstListener == null) {
@ -114,35 +113,35 @@ public class BiomeColorMenuFactory {
private final JMenu parentMenu; private final JMenu parentMenu;
private final Actions actions; private final Actions actions;
private final BiomeColorProfileDirectory biomeColorProfileDirectory; private final BiomeProfileDirectory biomeProfileDirectory;
public BiomeColorMenuFactory(JMenu parentMenu, Actions actions, public BiomeProfileMenuFactory(JMenu parentMenu, Actions actions,
BiomeColorProfileDirectory biomeColorProfileDirectory) { BiomeProfileDirectory biomeProfileDirectory) {
this.parentMenu = parentMenu; this.parentMenu = parentMenu;
this.actions = actions; this.actions = actions;
this.biomeColorProfileDirectory = biomeColorProfileDirectory; this.biomeProfileDirectory = biomeProfileDirectory;
Log.i("Checking for additional biome color profiles."); Log.i("Checking for additional biome profiles.");
initParentMenu(); initParentMenu();
} }
private void initParentMenu() { private void initParentMenu() {
parentMenu.removeAll(); parentMenu.removeAll();
biomeColorProfileDirectory.saveDefaultProfileIfNecessary(); biomeProfileDirectory.saveDefaultProfileIfNecessary();
BiomeColorProfileVisitorImpl visitor = new BiomeColorProfileVisitorImpl( BiomeProfileVisitorImpl visitor = new BiomeProfileVisitorImpl(
parentMenu, actions); parentMenu, actions);
biomeColorProfileDirectory.visitProfiles(visitor); biomeProfileDirectory.visitProfiles(visitor);
parentMenu.add(createReloadMenuItem()); parentMenu.add(createReloadMenuItem());
visitor.selectFirstProfile(); visitor.selectFirstProfile();
} }
private JMenuItem createReloadMenuItem() { private JMenuItem createReloadMenuItem() {
final JMenuItem result = new JMenuItem("Reload biome color profiles"); final JMenuItem result = new JMenuItem("Reload biome profiles");
result.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_B, result.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_B,
InputEvent.CTRL_DOWN_MASK)); InputEvent.CTRL_DOWN_MASK));
result.addActionListener(new ActionListener() { result.addActionListener(new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent arg) { public void actionPerformed(ActionEvent arg) {
Log.i("Reloading additional biome color profiles."); Log.i("Reloading additional biome profiles.");
initParentMenu(); initParentMenu();
} }
}); });

View File

@ -15,7 +15,7 @@ import amidst.fragment.layer.LayerReloader;
import amidst.gui.main.viewer.BiomeSelection; import amidst.gui.main.viewer.BiomeSelection;
import amidst.mojangapi.world.biome.Biome; import amidst.mojangapi.world.biome.Biome;
import amidst.mojangapi.world.biome.BiomeColor; import amidst.mojangapi.world.biome.BiomeColor;
import amidst.settings.biomecolorprofile.BiomeColorProfileSelection; import amidst.settings.biomeprofile.BiomeProfileSelection;
@NotThreadSafe @NotThreadSafe
public class BiomeWidget extends Widget { public class BiomeWidget extends Widget {
@ -33,7 +33,7 @@ public class BiomeWidget extends Widget {
private final BiomeSelection biomeSelection; private final BiomeSelection biomeSelection;
private final LayerReloader layerReloader; private final LayerReloader layerReloader;
private final BiomeColorProfileSelection biomeColorProfileSelection; private final BiomeProfileSelection biomeProfileSelection;
private List<Biome> biomes = new ArrayList<Biome>(); private List<Biome> biomes = new ArrayList<Biome>();
private int maxNameWidth = 0; private int maxNameWidth = 0;
@ -54,11 +54,11 @@ public class BiomeWidget extends Widget {
@CalledOnlyBy(AmidstThread.EDT) @CalledOnlyBy(AmidstThread.EDT)
public BiomeWidget(CornerAnchorPoint anchor, BiomeSelection biomeSelection, public BiomeWidget(CornerAnchorPoint anchor, BiomeSelection biomeSelection,
LayerReloader layerReloader, LayerReloader layerReloader,
BiomeColorProfileSelection biomeColorProfileSelection) { BiomeProfileSelection biomeProfileSelection) {
super(anchor); super(anchor);
this.biomeSelection = biomeSelection; this.biomeSelection = biomeSelection;
this.layerReloader = layerReloader; this.layerReloader = layerReloader;
this.biomeColorProfileSelection = biomeColorProfileSelection; this.biomeProfileSelection = biomeProfileSelection;
setWidth(250); setWidth(250);
setHeight(400); setHeight(400);
setY(100); setY(100);
@ -217,8 +217,7 @@ public class BiomeWidget extends Widget {
@CalledOnlyBy(AmidstThread.EDT) @CalledOnlyBy(AmidstThread.EDT)
private BiomeColor getBiomeColorOrUnknown(Biome biome) { private BiomeColor getBiomeColorOrUnknown(Biome biome) {
return biomeColorProfileSelection.getBiomeColorOrUnknown(biome return biomeProfileSelection.getBiomeColorOrUnknown(biome.getIndex());
.getIndex());
} }
@CalledOnlyBy(AmidstThread.EDT) @CalledOnlyBy(AmidstThread.EDT)

View File

@ -63,7 +63,7 @@ public class WidgetBuilder {
new DebugWidget( CornerAnchorPoint.BOTTOM_RIGHT, graph, fragmentManager, settings.showDebug, accelerationCounter), new DebugWidget( CornerAnchorPoint.BOTTOM_RIGHT, graph, fragmentManager, settings.showDebug, accelerationCounter),
new CursorInformationWidget(CornerAnchorPoint.TOP_RIGHT, graph, translator, settings.dimension), new CursorInformationWidget(CornerAnchorPoint.TOP_RIGHT, graph, translator, settings.dimension),
new BiomeToggleWidget( CornerAnchorPoint.BOTTOM_RIGHT, biomeSelection, layerReloader), new BiomeToggleWidget( CornerAnchorPoint.BOTTOM_RIGHT, biomeSelection, layerReloader),
new BiomeWidget( CornerAnchorPoint.NONE, biomeSelection, layerReloader, settings.biomeColorProfileSelection) new BiomeWidget( CornerAnchorPoint.NONE, biomeSelection, layerReloader, settings.biomeProfileSelection)
); );
// @formatter:on // @formatter:on
} }

View File

@ -3,7 +3,7 @@ package amidst.mojangapi.world.biome;
import java.awt.Color; import java.awt.Color;
import amidst.documentation.Immutable; import amidst.documentation.Immutable;
import amidst.settings.biomecolorprofile.BiomeColorJson; import amidst.settings.biomeprofile.BiomeColorJson;
@Immutable @Immutable
public class BiomeColor { public class BiomeColor {

View File

@ -1,9 +0,0 @@
package amidst.settings.biomecolorprofile;
public interface BiomeColorProfileVisitor {
void enterDirectory(String name);
void visitProfile(BiomeColorProfile profile);
void leaveDirectory();
}

View File

@ -1,4 +1,4 @@
package amidst.settings.biomecolorprofile; package amidst.settings.biomeprofile;
import amidst.documentation.GsonConstructor; import amidst.documentation.GsonConstructor;
import amidst.documentation.Immutable; import amidst.documentation.Immutable;

View File

@ -1,4 +1,4 @@
package amidst.settings.biomecolorprofile; package amidst.settings.biomeprofile;
import java.io.BufferedWriter; import java.io.BufferedWriter;
import java.io.File; import java.io.File;
@ -18,7 +18,7 @@ import amidst.mojangapi.world.biome.Biome;
import amidst.mojangapi.world.biome.BiomeColor; import amidst.mojangapi.world.biome.BiomeColor;
@Immutable @Immutable
public class BiomeColorProfile { public class BiomeProfile {
private static Map<String, BiomeColorJson> createDefaultColorMap() { private static Map<String, BiomeColorJson> createDefaultColorMap() {
Map<String, BiomeColorJson> result = new HashMap<String, BiomeColorJson>(); Map<String, BiomeColorJson> result = new HashMap<String, BiomeColorJson>();
for (Biome biome : Biome.allBiomes()) { for (Biome biome : Biome.allBiomes()) {
@ -28,11 +28,11 @@ public class BiomeColorProfile {
return result; return result;
} }
public static BiomeColorProfile getDefaultProfile() { public static BiomeProfile getDefaultProfile() {
return DEFAULT_PROFILE; return DEFAULT_PROFILE;
} }
private static final BiomeColorProfile DEFAULT_PROFILE = new BiomeColorProfile( private static final BiomeProfile DEFAULT_PROFILE = new BiomeProfile(
"default", null, createDefaultColorMap()); "default", null, createDefaultColorMap());
private volatile String name; private volatile String name;
@ -40,10 +40,10 @@ public class BiomeColorProfile {
private volatile Map<String, BiomeColorJson> colorMap; private volatile Map<String, BiomeColorJson> colorMap;
@GsonConstructor @GsonConstructor
public BiomeColorProfile() { public BiomeProfile() {
} }
private BiomeColorProfile(String name, String shortcut, private BiomeProfile(String name, String shortcut,
Map<String, BiomeColorJson> colorMap) { Map<String, BiomeColorJson> colorMap) {
this.name = name; this.name = name;
this.shortcut = shortcut; this.shortcut = shortcut;

View File

@ -1,4 +1,4 @@
package amidst.settings.biomecolorprofile; package amidst.settings.biomeprofile;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.File; import java.io.File;
@ -13,11 +13,10 @@ import com.google.gson.JsonIOException;
import com.google.gson.JsonSyntaxException; import com.google.gson.JsonSyntaxException;
@Immutable @Immutable
public class BiomeColorProfileDirectory { public class BiomeProfileDirectory {
public static BiomeColorProfileDirectory create(String root) { public static BiomeProfileDirectory create(String root) {
BiomeColorProfileDirectory result = new BiomeColorProfileDirectory( BiomeProfileDirectory result = new BiomeProfileDirectory(getRoot(root));
getRoot(root)); Log.i("using biome profiles at: '" + result.getRoot() + "'");
Log.i("using biome color profiles at: '" + result.getRoot() + "'");
return result; return result;
} }
@ -29,14 +28,13 @@ public class BiomeColorProfileDirectory {
} }
} }
private static final File DEFAULT_ROOT_DIRECTORY = new File( private static final File DEFAULT_ROOT_DIRECTORY = new File("biome");
"biome-color-profiles");
private static final Gson GSON = new Gson(); private static final Gson GSON = new Gson();
private final File root; private final File root;
private final File defaultProfile; private final File defaultProfile;
public BiomeColorProfileDirectory(File root) { public BiomeProfileDirectory(File root) {
this.root = root; this.root = root;
this.defaultProfile = new File(root, "default.json"); this.defaultProfile = new File(root, "default.json");
} }
@ -55,29 +53,28 @@ public class BiomeColorProfileDirectory {
public void saveDefaultProfileIfNecessary() { public void saveDefaultProfileIfNecessary() {
if (!isValid()) { if (!isValid()) {
Log.i("Unable to find biome color profile directory."); Log.i("Unable to find biome profile directory.");
} else { } else {
Log.i("Found biome color profile directory."); Log.i("Found biome profile directory.");
if (defaultProfile.isFile()) { if (defaultProfile.isFile()) {
Log.i("Found default biome color profile."); Log.i("Found default biome profile.");
} else if (BiomeColorProfile.getDefaultProfile().save( } else if (BiomeProfile.getDefaultProfile().save(defaultProfile)) {
defaultProfile)) { Log.i("Saved default biome profile.");
Log.i("Saved default biome color profile.");
} else { } else {
Log.i("Attempted to save default biome color profile, but encountered an error."); Log.i("Attempted to save default biome profile, but encountered an error.");
} }
} }
} }
public void visitProfiles(BiomeColorProfileVisitor visitor) { public void visitProfiles(BiomeProfileVisitor visitor) {
visitProfiles(root, visitor); visitProfiles(root, visitor);
} }
private void visitProfiles(File directory, BiomeColorProfileVisitor visitor) { private void visitProfiles(File directory, BiomeProfileVisitor visitor) {
boolean entered = false; boolean entered = false;
for (File file : directory.listFiles()) { for (File file : directory.listFiles()) {
if (file.isFile()) { if (file.isFile()) {
BiomeColorProfile profile = createFromFile(file); BiomeProfile profile = createFromFile(file);
if (profile != null) { if (profile != null) {
if (!entered) { if (!entered) {
entered = true; entered = true;
@ -94,8 +91,8 @@ public class BiomeColorProfileDirectory {
} }
} }
private BiomeColorProfile createFromFile(File file) { private BiomeProfile createFromFile(File file) {
BiomeColorProfile profile = null; BiomeProfile profile = null;
if (file.exists() && file.isFile()) { if (file.exists() && file.isFile()) {
try { try {
profile = readProfile(file); profile = readProfile(file);
@ -112,10 +109,10 @@ public class BiomeColorProfileDirectory {
return profile; return profile;
} }
private BiomeColorProfile readProfile(File file) throws IOException, private BiomeProfile readProfile(File file) throws IOException,
JsonSyntaxException, JsonIOException { JsonSyntaxException, JsonIOException {
try (BufferedReader reader = new BufferedReader(new FileReader(file))) { try (BufferedReader reader = new BufferedReader(new FileReader(file))) {
return GSON.fromJson(reader, BiomeColorProfile.class); return GSON.fromJson(reader, BiomeProfile.class);
} }
} }
} }

View File

@ -1,4 +1,4 @@
package amidst.settings.biomecolorprofile; package amidst.settings.biomeprofile;
import amidst.documentation.ThreadSafe; import amidst.documentation.ThreadSafe;
import amidst.logging.Log; import amidst.logging.Log;
@ -6,11 +6,11 @@ import amidst.mojangapi.world.biome.BiomeColor;
import amidst.mojangapi.world.biome.UnknownBiomeIndexException; import amidst.mojangapi.world.biome.UnknownBiomeIndexException;
@ThreadSafe @ThreadSafe
public class BiomeColorProfileSelection { public class BiomeProfileSelection {
private volatile BiomeColor[] biomeColors; private volatile BiomeColor[] biomeColors;
public BiomeColorProfileSelection(BiomeColorProfile biomeColorProfile) { public BiomeProfileSelection(BiomeProfile biomeProfile) {
set(biomeColorProfile); set(biomeProfile);
} }
public BiomeColor getBiomeColorOrUnknown(int index) { public BiomeColor getBiomeColorOrUnknown(int index) {
@ -35,8 +35,8 @@ public class BiomeColorProfileSelection {
} }
} }
public void set(BiomeColorProfile biomeColorProfile) { public void set(BiomeProfile biomeProfile) {
this.biomeColors = biomeColorProfile.createBiomeColorArray(); this.biomeColors = biomeProfile.createBiomeColorArray();
Log.i("Biome color profile activated."); Log.i("Biome profile activated: " + biomeProfile.getName());
} }
} }

View File

@ -0,0 +1,9 @@
package amidst.settings.biomeprofile;
public interface BiomeProfileVisitor {
void enterDirectory(String name);
void visitProfile(BiomeProfile profile);
void leaveDirectory();
}