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
parent
b613946ff2
commit
a9dfdf184d
|
@ -9,8 +9,8 @@ import amidst.mojangapi.world.Dimension;
|
|||
import amidst.mojangapi.world.WorldType;
|
||||
import amidst.settings.Setting;
|
||||
import amidst.settings.Settings;
|
||||
import amidst.settings.biomecolorprofile.BiomeColorProfile;
|
||||
import amidst.settings.biomecolorprofile.BiomeColorProfileSelection;
|
||||
import amidst.settings.biomeprofile.BiomeProfile;
|
||||
import amidst.settings.biomeprofile.BiomeProfileSelection;
|
||||
|
||||
@ThreadSafe
|
||||
public class AmidstSettings {
|
||||
|
@ -41,7 +41,7 @@ public class AmidstSettings {
|
|||
/**
|
||||
* This is not persisted.
|
||||
*/
|
||||
public final BiomeColorProfileSelection biomeColorProfileSelection;
|
||||
public final BiomeProfileSelection biomeProfileSelection;
|
||||
|
||||
@CalledOnlyBy(AmidstThread.EDT)
|
||||
public AmidstSettings(Preferences preferences) {
|
||||
|
@ -69,7 +69,7 @@ public class AmidstSettings {
|
|||
|
||||
lastProfile = Settings.createString( preferences, "profile", "");
|
||||
worldType = Settings.createString( preferences, "worldType", WorldType.PROMPT_EACH_TIME);
|
||||
biomeColorProfileSelection = new BiomeColorProfileSelection(BiomeColorProfile.getDefaultProfile());
|
||||
biomeProfileSelection = new BiomeProfileSelection(BiomeProfile.getDefaultProfile());
|
||||
// @formatter:on
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ import amidst.mojangapi.minecraftinterface.local.LocalMinecraftInterfaceCreation
|
|||
import amidst.mojangapi.world.SeedHistoryLogger;
|
||||
import amidst.mojangapi.world.WorldBuilder;
|
||||
import amidst.mojangapi.world.player.PlayerInformationCacheImpl;
|
||||
import amidst.settings.biomecolorprofile.BiomeColorProfileDirectory;
|
||||
import amidst.settings.biomeprofile.BiomeProfileDirectory;
|
||||
import amidst.threading.ThreadMaster;
|
||||
|
||||
@NotThreadSafe
|
||||
|
@ -27,7 +27,7 @@ public class Application {
|
|||
private final AmidstMetaData metadata;
|
||||
private final AmidstSettings settings;
|
||||
private final MojangApi mojangApi;
|
||||
private final BiomeColorProfileDirectory biomeColorProfileDirectory;
|
||||
private final BiomeProfileDirectory biomeProfileDirectory;
|
||||
private final ViewerFacadeBuilder viewerFacadeBuilder;
|
||||
private final ThreadMaster threadMaster;
|
||||
|
||||
|
@ -42,7 +42,7 @@ public class Application {
|
|||
this.metadata = metadata;
|
||||
this.settings = createSettings();
|
||||
this.mojangApi = createMojangApi();
|
||||
this.biomeColorProfileDirectory = createBiomeColorProfileDirectory();
|
||||
this.biomeProfileDirectory = createBiomeProfileDirectory();
|
||||
this.viewerFacadeBuilder = createViewerFacadeBuilder();
|
||||
this.threadMaster = createThreadMaster();
|
||||
}
|
||||
|
@ -63,9 +63,8 @@ public class Application {
|
|||
}
|
||||
|
||||
@CalledOnlyBy(AmidstThread.EDT)
|
||||
private BiomeColorProfileDirectory createBiomeColorProfileDirectory() {
|
||||
return BiomeColorProfileDirectory
|
||||
.create(parameters.biomeColorProfilesDirectory);
|
||||
private BiomeProfileDirectory createBiomeProfileDirectory() {
|
||||
return BiomeProfileDirectory.create(parameters.biomeProfilesDirectory);
|
||||
}
|
||||
|
||||
@CalledOnlyBy(AmidstThread.EDT)
|
||||
|
@ -103,7 +102,7 @@ public class Application {
|
|||
@CalledOnlyBy(AmidstThread.EDT)
|
||||
public void displayMainWindow() {
|
||||
setMainWindow(new MainWindow(this, metadata, settings, mojangApi,
|
||||
biomeColorProfileDirectory, viewerFacadeBuilder, threadMaster));
|
||||
biomeProfileDirectory, viewerFacadeBuilder, threadMaster));
|
||||
setProfileSelectWindow(null);
|
||||
}
|
||||
|
||||
|
|
|
@ -23,8 +23,8 @@ public class CommandLineParameters {
|
|||
@Option(name = "-mcjson", usage = "location of the minecraft json file", metaVar = "<file>", depends = { "-mcjar" })
|
||||
public volatile String minecraftJsonFile;
|
||||
|
||||
@Option(name = "-biome-color-profiles", usage = "location of the biome color profile directory", metaVar = "<directory>")
|
||||
public volatile String biomeColorProfilesDirectory;
|
||||
@Option(name = "-biome-profiles", usage = "location of the biome profile directory", metaVar = "<directory>")
|
||||
public volatile String biomeProfilesDirectory;
|
||||
|
||||
@Option(name = "-history", usage = "location of the seed history file", metaVar = "<file>")
|
||||
public volatile String historyFile;
|
||||
|
|
|
@ -5,17 +5,17 @@ import amidst.fragment.Fragment;
|
|||
import amidst.gui.main.viewer.BiomeSelection;
|
||||
import amidst.mojangapi.world.Dimension;
|
||||
import amidst.mojangapi.world.biome.BiomeColor;
|
||||
import amidst.settings.biomecolorprofile.BiomeColorProfileSelection;
|
||||
import amidst.settings.biomeprofile.BiomeProfileSelection;
|
||||
|
||||
@ThreadSafe
|
||||
public class BiomeColorProvider implements ColorProvider {
|
||||
private final BiomeSelection biomeSelection;
|
||||
private final BiomeColorProfileSelection biomeColorProfileSelection;
|
||||
private final BiomeProfileSelection biomeProfileSelection;
|
||||
|
||||
public BiomeColorProvider(BiomeSelection biomeSelection,
|
||||
BiomeColorProfileSelection biomeColorProfileSelection) {
|
||||
BiomeProfileSelection biomeProfileSelection) {
|
||||
this.biomeSelection = biomeSelection;
|
||||
this.biomeColorProfileSelection = biomeColorProfileSelection;
|
||||
this.biomeProfileSelection = biomeProfileSelection;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -33,6 +33,6 @@ public class BiomeColorProvider implements ColorProvider {
|
|||
}
|
||||
|
||||
private BiomeColor getBiomeColor(int biomeIndex) {
|
||||
return biomeColorProfileSelection.getBiomeColorOrUnknown(biomeIndex);
|
||||
return biomeProfileSelection.getBiomeColorOrUnknown(biomeIndex);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -124,7 +124,7 @@ public class LayerBuilder {
|
|||
new AlphaInitializer( declarations.get(LayerIds.ALPHA), settings.fragmentFading),
|
||||
new BiomeDataLoader( declarations.get(LayerIds.BIOME_DATA), world.getBiomeDataOracle()),
|
||||
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 WorldIconLoader<Void>( declarations.get(LayerIds.SPAWN), world.getSpawnProducer()),
|
||||
new WorldIconLoader<Void>( declarations.get(LayerIds.STRONGHOLD), world.getStrongholdProducer()),
|
||||
|
|
|
@ -28,8 +28,8 @@ import amidst.mojangapi.world.coordinates.CoordinatesInWorld;
|
|||
import amidst.mojangapi.world.icon.WorldIcon;
|
||||
import amidst.mojangapi.world.player.Player;
|
||||
import amidst.mojangapi.world.player.PlayerCoordinates;
|
||||
import amidst.settings.biomecolorprofile.BiomeColorProfile;
|
||||
import amidst.settings.biomecolorprofile.BiomeColorProfileSelection;
|
||||
import amidst.settings.biomeprofile.BiomeProfile;
|
||||
import amidst.settings.biomeprofile.BiomeProfileSelection;
|
||||
import amidst.threading.WorkerExecutor;
|
||||
|
||||
@NotThreadSafe
|
||||
|
@ -38,19 +38,19 @@ public class Actions {
|
|||
private final MojangApi mojangApi;
|
||||
private final MainWindow mainWindow;
|
||||
private final AtomicReference<ViewerFacade> viewerFacade;
|
||||
private final BiomeColorProfileSelection biomeColorProfileSelection;
|
||||
private final BiomeProfileSelection biomeProfileSelection;
|
||||
private final WorkerExecutor workerExecutor;
|
||||
|
||||
@CalledOnlyBy(AmidstThread.EDT)
|
||||
public Actions(Application application, MojangApi mojangApi,
|
||||
MainWindow mainWindow, AtomicReference<ViewerFacade> viewerFacade,
|
||||
BiomeColorProfileSelection biomeColorProfileSelection,
|
||||
BiomeProfileSelection biomeProfileSelection,
|
||||
WorkerExecutor workerExecutor) {
|
||||
this.application = application;
|
||||
this.mojangApi = mojangApi;
|
||||
this.mainWindow = mainWindow;
|
||||
this.viewerFacade = viewerFacade;
|
||||
this.biomeColorProfileSelection = biomeColorProfileSelection;
|
||||
this.biomeProfileSelection = biomeProfileSelection;
|
||||
this.workerExecutor = workerExecutor;
|
||||
}
|
||||
|
||||
|
@ -224,8 +224,8 @@ public class Actions {
|
|||
}
|
||||
|
||||
@CalledOnlyBy(AmidstThread.EDT)
|
||||
public void selectBiomeColorProfile(BiomeColorProfile profile) {
|
||||
biomeColorProfileSelection.set(profile);
|
||||
public void selectBiomeProfile(BiomeProfile profile) {
|
||||
biomeProfileSelection.set(profile);
|
||||
ViewerFacade viewerFacade = this.viewerFacade.get();
|
||||
if (viewerFacade != null) {
|
||||
viewerFacade.reloadBackgroundLayer();
|
||||
|
|
|
@ -32,7 +32,7 @@ import amidst.mojangapi.world.WorldSeed;
|
|||
import amidst.mojangapi.world.WorldType;
|
||||
import amidst.mojangapi.world.player.MovablePlayerList;
|
||||
import amidst.mojangapi.world.player.WorldPlayerType;
|
||||
import amidst.settings.biomecolorprofile.BiomeColorProfileDirectory;
|
||||
import amidst.settings.biomeprofile.BiomeProfileDirectory;
|
||||
import amidst.threading.ThreadMaster;
|
||||
|
||||
@NotThreadSafe
|
||||
|
@ -41,7 +41,7 @@ public class MainWindow {
|
|||
private final AmidstMetaData metadata;
|
||||
private final AmidstSettings settings;
|
||||
private final MojangApi mojangApi;
|
||||
private final BiomeColorProfileDirectory biomeColorProfileDirectory;
|
||||
private final BiomeProfileDirectory biomeProfileDirectory;
|
||||
private final ViewerFacadeBuilder viewerFacadeBuilder;
|
||||
private final ThreadMaster threadMaster;
|
||||
|
||||
|
@ -55,13 +55,13 @@ public class MainWindow {
|
|||
@CalledOnlyBy(AmidstThread.EDT)
|
||||
public MainWindow(Application application, AmidstMetaData metadata,
|
||||
AmidstSettings settings, MojangApi mojangApi,
|
||||
BiomeColorProfileDirectory biomeColorProfileDirectory,
|
||||
BiomeProfileDirectory biomeProfileDirectory,
|
||||
ViewerFacadeBuilder viewerFacadeBuilder, ThreadMaster threadMaster) {
|
||||
this.application = application;
|
||||
this.metadata = metadata;
|
||||
this.settings = settings;
|
||||
this.mojangApi = mojangApi;
|
||||
this.biomeColorProfileDirectory = biomeColorProfileDirectory;
|
||||
this.biomeProfileDirectory = biomeProfileDirectory;
|
||||
this.viewerFacadeBuilder = viewerFacadeBuilder;
|
||||
this.threadMaster = threadMaster;
|
||||
this.frame = createFrame();
|
||||
|
@ -104,14 +104,14 @@ public class MainWindow {
|
|||
@CalledOnlyBy(AmidstThread.EDT)
|
||||
private Actions createActions() {
|
||||
return new Actions(application, mojangApi, this, viewerFacade,
|
||||
settings.biomeColorProfileSelection,
|
||||
settings.biomeProfileSelection,
|
||||
threadMaster.getWorkerExecutor());
|
||||
}
|
||||
|
||||
@CalledOnlyBy(AmidstThread.EDT)
|
||||
private AmidstMenu createMenuBar() {
|
||||
AmidstMenu menuBar = new AmidstMenuBuilder(settings, actions,
|
||||
biomeColorProfileDirectory).construct();
|
||||
biomeProfileDirectory).construct();
|
||||
frame.setJMenuBar(menuBar.getMenuBar());
|
||||
return menuBar;
|
||||
}
|
||||
|
|
|
@ -10,13 +10,13 @@ import amidst.AmidstSettings;
|
|||
import amidst.documentation.NotThreadSafe;
|
||||
import amidst.gui.main.Actions;
|
||||
import amidst.mojangapi.world.WorldType;
|
||||
import amidst.settings.biomecolorprofile.BiomeColorProfileDirectory;
|
||||
import amidst.settings.biomeprofile.BiomeProfileDirectory;
|
||||
|
||||
@NotThreadSafe
|
||||
public class AmidstMenuBuilder {
|
||||
private final AmidstSettings settings;
|
||||
private final Actions actions;
|
||||
private final BiomeColorProfileDirectory biomeColorProfileDirectory;
|
||||
private final BiomeProfileDirectory biomeProfileDirectory;
|
||||
private final JMenuBar menuBar;
|
||||
private JMenu worldMenu;
|
||||
private JMenuItem savePlayerLocationsMenu;
|
||||
|
@ -24,10 +24,10 @@ public class AmidstMenuBuilder {
|
|||
private LayersMenu layersMenu;
|
||||
|
||||
public AmidstMenuBuilder(AmidstSettings settings, Actions actions,
|
||||
BiomeColorProfileDirectory biomeColorProfileDirectory) {
|
||||
BiomeProfileDirectory biomeProfileDirectory) {
|
||||
this.settings = settings;
|
||||
this.actions = actions;
|
||||
this.biomeColorProfileDirectory = biomeColorProfileDirectory;
|
||||
this.biomeProfileDirectory = biomeProfileDirectory;
|
||||
this.menuBar = createMenuBar();
|
||||
}
|
||||
|
||||
|
@ -95,8 +95,8 @@ public class AmidstMenuBuilder {
|
|||
JMenu result = new JMenu("Settings");
|
||||
result.setMnemonic(KeyEvent.VK_S);
|
||||
result.add(create_Settings_DefaultWorldType());
|
||||
if (biomeColorProfileDirectory.isValid()) {
|
||||
result.add(create_Settings_BiomeColor());
|
||||
if (biomeProfileDirectory.isValid()) {
|
||||
result.add(create_Settings_BiomeProfile());
|
||||
}
|
||||
result.addSeparator();
|
||||
// @formatter:off
|
||||
|
@ -118,9 +118,9 @@ public class AmidstMenuBuilder {
|
|||
return result;
|
||||
}
|
||||
|
||||
private JMenu create_Settings_BiomeColor() {
|
||||
JMenu result = new JMenu("Biome color profile");
|
||||
new BiomeColorMenuFactory(result, actions, biomeColorProfileDirectory);
|
||||
private JMenu create_Settings_BiomeProfile() {
|
||||
JMenu result = new JMenu("Biome profile");
|
||||
new BiomeProfileMenuFactory(result, actions, biomeProfileDirectory);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -15,15 +15,14 @@ import javax.swing.KeyStroke;
|
|||
import amidst.documentation.NotThreadSafe;
|
||||
import amidst.gui.main.Actions;
|
||||
import amidst.logging.Log;
|
||||
import amidst.settings.biomecolorprofile.BiomeColorProfile;
|
||||
import amidst.settings.biomecolorprofile.BiomeColorProfileDirectory;
|
||||
import amidst.settings.biomecolorprofile.BiomeColorProfileVisitor;
|
||||
import amidst.settings.biomeprofile.BiomeProfile;
|
||||
import amidst.settings.biomeprofile.BiomeProfileDirectory;
|
||||
import amidst.settings.biomeprofile.BiomeProfileVisitor;
|
||||
|
||||
@NotThreadSafe
|
||||
public class BiomeColorMenuFactory {
|
||||
public class BiomeProfileMenuFactory {
|
||||
@NotThreadSafe
|
||||
private static class BiomeColorProfileVisitorImpl implements
|
||||
BiomeColorProfileVisitor {
|
||||
private static class BiomeProfileVisitorImpl implements BiomeProfileVisitor {
|
||||
private final List<JCheckBoxMenuItem> allCheckBoxes = new ArrayList<JCheckBoxMenuItem>();
|
||||
private final List<JMenu> menuStack = new ArrayList<JMenu>();
|
||||
private ActionListener firstListener;
|
||||
|
@ -31,7 +30,7 @@ public class BiomeColorMenuFactory {
|
|||
|
||||
private final Actions actions;
|
||||
|
||||
private BiomeColorProfileVisitorImpl(JMenu parentMenu, Actions actions) {
|
||||
private BiomeProfileVisitorImpl(JMenu parentMenu, Actions actions) {
|
||||
this.actions = actions;
|
||||
menuStack.add(parentMenu);
|
||||
}
|
||||
|
@ -48,7 +47,7 @@ public class BiomeColorMenuFactory {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void visitProfile(BiomeColorProfile profile) {
|
||||
public void visitProfile(BiomeProfile profile) {
|
||||
JCheckBoxMenuItem checkBox = createCheckBox(profile);
|
||||
allCheckBoxes.add(checkBox);
|
||||
getLastMenu().add(checkBox);
|
||||
|
@ -67,7 +66,7 @@ public class BiomeColorMenuFactory {
|
|||
menuStack.remove(menuStack.size() - 1);
|
||||
}
|
||||
|
||||
private JCheckBoxMenuItem createCheckBox(BiomeColorProfile profile) {
|
||||
private JCheckBoxMenuItem createCheckBox(BiomeProfile profile) {
|
||||
JCheckBoxMenuItem result = new JCheckBoxMenuItem(profile.getName());
|
||||
tryCreateKeyboardShortcut(profile.getShortcut(), 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) {
|
||||
ActionListener result = new ActionListener() {
|
||||
@Override
|
||||
|
@ -96,7 +95,7 @@ public class BiomeColorMenuFactory {
|
|||
checkBox.setSelected(false);
|
||||
}
|
||||
selectedCheckBox.setSelected(true);
|
||||
actions.selectBiomeColorProfile(profile);
|
||||
actions.selectBiomeProfile(profile);
|
||||
}
|
||||
};
|
||||
if (firstListener == null) {
|
||||
|
@ -114,35 +113,35 @@ public class BiomeColorMenuFactory {
|
|||
|
||||
private final JMenu parentMenu;
|
||||
private final Actions actions;
|
||||
private final BiomeColorProfileDirectory biomeColorProfileDirectory;
|
||||
private final BiomeProfileDirectory biomeProfileDirectory;
|
||||
|
||||
public BiomeColorMenuFactory(JMenu parentMenu, Actions actions,
|
||||
BiomeColorProfileDirectory biomeColorProfileDirectory) {
|
||||
public BiomeProfileMenuFactory(JMenu parentMenu, Actions actions,
|
||||
BiomeProfileDirectory biomeProfileDirectory) {
|
||||
this.parentMenu = parentMenu;
|
||||
this.actions = actions;
|
||||
this.biomeColorProfileDirectory = biomeColorProfileDirectory;
|
||||
Log.i("Checking for additional biome color profiles.");
|
||||
this.biomeProfileDirectory = biomeProfileDirectory;
|
||||
Log.i("Checking for additional biome profiles.");
|
||||
initParentMenu();
|
||||
}
|
||||
|
||||
private void initParentMenu() {
|
||||
parentMenu.removeAll();
|
||||
biomeColorProfileDirectory.saveDefaultProfileIfNecessary();
|
||||
BiomeColorProfileVisitorImpl visitor = new BiomeColorProfileVisitorImpl(
|
||||
biomeProfileDirectory.saveDefaultProfileIfNecessary();
|
||||
BiomeProfileVisitorImpl visitor = new BiomeProfileVisitorImpl(
|
||||
parentMenu, actions);
|
||||
biomeColorProfileDirectory.visitProfiles(visitor);
|
||||
biomeProfileDirectory.visitProfiles(visitor);
|
||||
parentMenu.add(createReloadMenuItem());
|
||||
visitor.selectFirstProfile();
|
||||
}
|
||||
|
||||
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,
|
||||
InputEvent.CTRL_DOWN_MASK));
|
||||
result.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent arg) {
|
||||
Log.i("Reloading additional biome color profiles.");
|
||||
Log.i("Reloading additional biome profiles.");
|
||||
initParentMenu();
|
||||
}
|
||||
});
|
|
@ -15,7 +15,7 @@ import amidst.fragment.layer.LayerReloader;
|
|||
import amidst.gui.main.viewer.BiomeSelection;
|
||||
import amidst.mojangapi.world.biome.Biome;
|
||||
import amidst.mojangapi.world.biome.BiomeColor;
|
||||
import amidst.settings.biomecolorprofile.BiomeColorProfileSelection;
|
||||
import amidst.settings.biomeprofile.BiomeProfileSelection;
|
||||
|
||||
@NotThreadSafe
|
||||
public class BiomeWidget extends Widget {
|
||||
|
@ -33,7 +33,7 @@ public class BiomeWidget extends Widget {
|
|||
|
||||
private final BiomeSelection biomeSelection;
|
||||
private final LayerReloader layerReloader;
|
||||
private final BiomeColorProfileSelection biomeColorProfileSelection;
|
||||
private final BiomeProfileSelection biomeProfileSelection;
|
||||
|
||||
private List<Biome> biomes = new ArrayList<Biome>();
|
||||
private int maxNameWidth = 0;
|
||||
|
@ -54,11 +54,11 @@ public class BiomeWidget extends Widget {
|
|||
@CalledOnlyBy(AmidstThread.EDT)
|
||||
public BiomeWidget(CornerAnchorPoint anchor, BiomeSelection biomeSelection,
|
||||
LayerReloader layerReloader,
|
||||
BiomeColorProfileSelection biomeColorProfileSelection) {
|
||||
BiomeProfileSelection biomeProfileSelection) {
|
||||
super(anchor);
|
||||
this.biomeSelection = biomeSelection;
|
||||
this.layerReloader = layerReloader;
|
||||
this.biomeColorProfileSelection = biomeColorProfileSelection;
|
||||
this.biomeProfileSelection = biomeProfileSelection;
|
||||
setWidth(250);
|
||||
setHeight(400);
|
||||
setY(100);
|
||||
|
@ -217,8 +217,7 @@ public class BiomeWidget extends Widget {
|
|||
|
||||
@CalledOnlyBy(AmidstThread.EDT)
|
||||
private BiomeColor getBiomeColorOrUnknown(Biome biome) {
|
||||
return biomeColorProfileSelection.getBiomeColorOrUnknown(biome
|
||||
.getIndex());
|
||||
return biomeProfileSelection.getBiomeColorOrUnknown(biome.getIndex());
|
||||
}
|
||||
|
||||
@CalledOnlyBy(AmidstThread.EDT)
|
||||
|
|
|
@ -63,7 +63,7 @@ public class WidgetBuilder {
|
|||
new DebugWidget( CornerAnchorPoint.BOTTOM_RIGHT, graph, fragmentManager, settings.showDebug, accelerationCounter),
|
||||
new CursorInformationWidget(CornerAnchorPoint.TOP_RIGHT, graph, translator, settings.dimension),
|
||||
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
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ package amidst.mojangapi.world.biome;
|
|||
import java.awt.Color;
|
||||
|
||||
import amidst.documentation.Immutable;
|
||||
import amidst.settings.biomecolorprofile.BiomeColorJson;
|
||||
import amidst.settings.biomeprofile.BiomeColorJson;
|
||||
|
||||
@Immutable
|
||||
public class BiomeColor {
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
package amidst.settings.biomecolorprofile;
|
||||
|
||||
public interface BiomeColorProfileVisitor {
|
||||
void enterDirectory(String name);
|
||||
|
||||
void visitProfile(BiomeColorProfile profile);
|
||||
|
||||
void leaveDirectory();
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package amidst.settings.biomecolorprofile;
|
||||
package amidst.settings.biomeprofile;
|
||||
|
||||
import amidst.documentation.GsonConstructor;
|
||||
import amidst.documentation.Immutable;
|
|
@ -1,4 +1,4 @@
|
|||
package amidst.settings.biomecolorprofile;
|
||||
package amidst.settings.biomeprofile;
|
||||
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
|
@ -18,7 +18,7 @@ import amidst.mojangapi.world.biome.Biome;
|
|||
import amidst.mojangapi.world.biome.BiomeColor;
|
||||
|
||||
@Immutable
|
||||
public class BiomeColorProfile {
|
||||
public class BiomeProfile {
|
||||
private static Map<String, BiomeColorJson> createDefaultColorMap() {
|
||||
Map<String, BiomeColorJson> result = new HashMap<String, BiomeColorJson>();
|
||||
for (Biome biome : Biome.allBiomes()) {
|
||||
|
@ -28,11 +28,11 @@ public class BiomeColorProfile {
|
|||
return result;
|
||||
}
|
||||
|
||||
public static BiomeColorProfile getDefaultProfile() {
|
||||
public static BiomeProfile getDefaultProfile() {
|
||||
return DEFAULT_PROFILE;
|
||||
}
|
||||
|
||||
private static final BiomeColorProfile DEFAULT_PROFILE = new BiomeColorProfile(
|
||||
private static final BiomeProfile DEFAULT_PROFILE = new BiomeProfile(
|
||||
"default", null, createDefaultColorMap());
|
||||
|
||||
private volatile String name;
|
||||
|
@ -40,10 +40,10 @@ public class BiomeColorProfile {
|
|||
private volatile Map<String, BiomeColorJson> colorMap;
|
||||
|
||||
@GsonConstructor
|
||||
public BiomeColorProfile() {
|
||||
public BiomeProfile() {
|
||||
}
|
||||
|
||||
private BiomeColorProfile(String name, String shortcut,
|
||||
private BiomeProfile(String name, String shortcut,
|
||||
Map<String, BiomeColorJson> colorMap) {
|
||||
this.name = name;
|
||||
this.shortcut = shortcut;
|
|
@ -1,4 +1,4 @@
|
|||
package amidst.settings.biomecolorprofile;
|
||||
package amidst.settings.biomeprofile;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
|
@ -13,11 +13,10 @@ import com.google.gson.JsonIOException;
|
|||
import com.google.gson.JsonSyntaxException;
|
||||
|
||||
@Immutable
|
||||
public class BiomeColorProfileDirectory {
|
||||
public static BiomeColorProfileDirectory create(String root) {
|
||||
BiomeColorProfileDirectory result = new BiomeColorProfileDirectory(
|
||||
getRoot(root));
|
||||
Log.i("using biome color profiles at: '" + result.getRoot() + "'");
|
||||
public class BiomeProfileDirectory {
|
||||
public static BiomeProfileDirectory create(String root) {
|
||||
BiomeProfileDirectory result = new BiomeProfileDirectory(getRoot(root));
|
||||
Log.i("using biome profiles at: '" + result.getRoot() + "'");
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -29,14 +28,13 @@ public class BiomeColorProfileDirectory {
|
|||
}
|
||||
}
|
||||
|
||||
private static final File DEFAULT_ROOT_DIRECTORY = new File(
|
||||
"biome-color-profiles");
|
||||
private static final File DEFAULT_ROOT_DIRECTORY = new File("biome");
|
||||
private static final Gson GSON = new Gson();
|
||||
|
||||
private final File root;
|
||||
private final File defaultProfile;
|
||||
|
||||
public BiomeColorProfileDirectory(File root) {
|
||||
public BiomeProfileDirectory(File root) {
|
||||
this.root = root;
|
||||
this.defaultProfile = new File(root, "default.json");
|
||||
}
|
||||
|
@ -55,29 +53,28 @@ public class BiomeColorProfileDirectory {
|
|||
|
||||
public void saveDefaultProfileIfNecessary() {
|
||||
if (!isValid()) {
|
||||
Log.i("Unable to find biome color profile directory.");
|
||||
Log.i("Unable to find biome profile directory.");
|
||||
} else {
|
||||
Log.i("Found biome color profile directory.");
|
||||
Log.i("Found biome profile directory.");
|
||||
if (defaultProfile.isFile()) {
|
||||
Log.i("Found default biome color profile.");
|
||||
} else if (BiomeColorProfile.getDefaultProfile().save(
|
||||
defaultProfile)) {
|
||||
Log.i("Saved default biome color profile.");
|
||||
Log.i("Found default biome profile.");
|
||||
} else if (BiomeProfile.getDefaultProfile().save(defaultProfile)) {
|
||||
Log.i("Saved default biome profile.");
|
||||
} 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);
|
||||
}
|
||||
|
||||
private void visitProfiles(File directory, BiomeColorProfileVisitor visitor) {
|
||||
private void visitProfiles(File directory, BiomeProfileVisitor visitor) {
|
||||
boolean entered = false;
|
||||
for (File file : directory.listFiles()) {
|
||||
if (file.isFile()) {
|
||||
BiomeColorProfile profile = createFromFile(file);
|
||||
BiomeProfile profile = createFromFile(file);
|
||||
if (profile != null) {
|
||||
if (!entered) {
|
||||
entered = true;
|
||||
|
@ -94,8 +91,8 @@ public class BiomeColorProfileDirectory {
|
|||
}
|
||||
}
|
||||
|
||||
private BiomeColorProfile createFromFile(File file) {
|
||||
BiomeColorProfile profile = null;
|
||||
private BiomeProfile createFromFile(File file) {
|
||||
BiomeProfile profile = null;
|
||||
if (file.exists() && file.isFile()) {
|
||||
try {
|
||||
profile = readProfile(file);
|
||||
|
@ -112,10 +109,10 @@ public class BiomeColorProfileDirectory {
|
|||
return profile;
|
||||
}
|
||||
|
||||
private BiomeColorProfile readProfile(File file) throws IOException,
|
||||
private BiomeProfile readProfile(File file) throws IOException,
|
||||
JsonSyntaxException, JsonIOException {
|
||||
try (BufferedReader reader = new BufferedReader(new FileReader(file))) {
|
||||
return GSON.fromJson(reader, BiomeColorProfile.class);
|
||||
return GSON.fromJson(reader, BiomeProfile.class);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package amidst.settings.biomecolorprofile;
|
||||
package amidst.settings.biomeprofile;
|
||||
|
||||
import amidst.documentation.ThreadSafe;
|
||||
import amidst.logging.Log;
|
||||
|
@ -6,11 +6,11 @@ import amidst.mojangapi.world.biome.BiomeColor;
|
|||
import amidst.mojangapi.world.biome.UnknownBiomeIndexException;
|
||||
|
||||
@ThreadSafe
|
||||
public class BiomeColorProfileSelection {
|
||||
public class BiomeProfileSelection {
|
||||
private volatile BiomeColor[] biomeColors;
|
||||
|
||||
public BiomeColorProfileSelection(BiomeColorProfile biomeColorProfile) {
|
||||
set(biomeColorProfile);
|
||||
public BiomeProfileSelection(BiomeProfile biomeProfile) {
|
||||
set(biomeProfile);
|
||||
}
|
||||
|
||||
public BiomeColor getBiomeColorOrUnknown(int index) {
|
||||
|
@ -35,8 +35,8 @@ public class BiomeColorProfileSelection {
|
|||
}
|
||||
}
|
||||
|
||||
public void set(BiomeColorProfile biomeColorProfile) {
|
||||
this.biomeColors = biomeColorProfile.createBiomeColorArray();
|
||||
Log.i("Biome color profile activated.");
|
||||
public void set(BiomeProfile biomeProfile) {
|
||||
this.biomeColors = biomeProfile.createBiomeColorArray();
|
||||
Log.i("Biome profile activated: " + biomeProfile.getName());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
package amidst.settings.biomeprofile;
|
||||
|
||||
public interface BiomeProfileVisitor {
|
||||
void enterDirectory(String name);
|
||||
|
||||
void visitProfile(BiomeProfile profile);
|
||||
|
||||
void leaveDirectory();
|
||||
}
|
Loading…
Reference in New Issue