more translation keys + generator defaults
This commit is contained in:
parent
2e1d9bda9c
commit
2ac7356888
@ -39,6 +39,7 @@
|
|||||||
"display.terraforged.climate.temperature.max": "Max",
|
"display.terraforged.climate.temperature.max": "Max",
|
||||||
"display.terraforged.climate.temperature.min": "Min",
|
"display.terraforged.climate.temperature.min": "Min",
|
||||||
"display.terraforged.climate.temperature.scale": "Scale",
|
"display.terraforged.climate.temperature.scale": "Scale",
|
||||||
|
"display.terraforged.climate.title": "Climate Settings",
|
||||||
"display.terraforged.dimensions": "Dimensions",
|
"display.terraforged.dimensions": "Dimensions",
|
||||||
"display.terraforged.dimensions.bedrock_layer": "Bedrock Layer",
|
"display.terraforged.dimensions.bedrock_layer": "Bedrock Layer",
|
||||||
"display.terraforged.dimensions.bedrock_layer.material": "Material",
|
"display.terraforged.dimensions.bedrock_layer.material": "Material",
|
||||||
@ -59,6 +60,9 @@
|
|||||||
"display.terraforged.filters.smoothing.iterations": "Iterations",
|
"display.terraforged.filters.smoothing.iterations": "Iterations",
|
||||||
"display.terraforged.filters.smoothing.smoothing_radius": "Smoothing Radius",
|
"display.terraforged.filters.smoothing.smoothing_radius": "Smoothing Radius",
|
||||||
"display.terraforged.filters.smoothing.smoothing_rate": "Smoothing Rate",
|
"display.terraforged.filters.smoothing.smoothing_rate": "Smoothing Rate",
|
||||||
|
"display.terraforged.filters.title": "Filter Settings",
|
||||||
|
"display.terraforged.general.cancel": "Cancel",
|
||||||
|
"display.terraforged.general.done": "Done",
|
||||||
"display.terraforged.miscellaneous": "Miscellaneous",
|
"display.terraforged.miscellaneous": "Miscellaneous",
|
||||||
"display.terraforged.miscellaneous.custom_biome_features": "Custom Biome Features",
|
"display.terraforged.miscellaneous.custom_biome_features": "Custom Biome Features",
|
||||||
"display.terraforged.miscellaneous.erosion_decorator": "Erosion Decorator",
|
"display.terraforged.miscellaneous.erosion_decorator": "Erosion Decorator",
|
||||||
@ -66,10 +70,23 @@
|
|||||||
"display.terraforged.miscellaneous.natural_snow_decorator": "Natural Snow Decorator",
|
"display.terraforged.miscellaneous.natural_snow_decorator": "Natural Snow Decorator",
|
||||||
"display.terraforged.miscellaneous.smooth_layer_decorator": "Smooth Layer Decorator",
|
"display.terraforged.miscellaneous.smooth_layer_decorator": "Smooth Layer Decorator",
|
||||||
"display.terraforged.miscellaneous.strata_decorator": "Strata Decorator",
|
"display.terraforged.miscellaneous.strata_decorator": "Strata Decorator",
|
||||||
|
"display.terraforged.miscellaneous.title": "Miscellaneous Settings",
|
||||||
"display.terraforged.miscellaneous.vanilla_water_features": "Vanilla Water Features",
|
"display.terraforged.miscellaneous.vanilla_water_features": "Vanilla Water Features",
|
||||||
|
"display.terraforged.preset.create": "Create",
|
||||||
|
"display.terraforged.preset.default": "Make Default",
|
||||||
|
"display.terraforged.preset.delete": "Delete",
|
||||||
|
"display.terraforged.preset.load": "Load",
|
||||||
|
"display.terraforged.preset.reset": "Reset",
|
||||||
|
"display.terraforged.preset.save": "Save",
|
||||||
|
"display.terraforged.presets.title": "Presets & Defaults",
|
||||||
"display.terraforged.preview": "Preview",
|
"display.terraforged.preview": "Preview",
|
||||||
|
"display.terraforged.preview.area": "Area: ",
|
||||||
|
"display.terraforged.preview.biome": "Biome: ",
|
||||||
"display.terraforged.preview.display": "Display",
|
"display.terraforged.preview.display": "Display",
|
||||||
|
"display.terraforged.preview.seed": "New Seed",
|
||||||
|
"display.terraforged.preview.terrain": "Terrain: ",
|
||||||
"display.terraforged.preview.zoom": "Zoom",
|
"display.terraforged.preview.zoom": "Zoom",
|
||||||
|
"display.terraforged.river.title": "River Settings",
|
||||||
"display.terraforged.rivers": "Rivers",
|
"display.terraforged.rivers": "Rivers",
|
||||||
"display.terraforged.rivers.primary_rivers": "Primary Rivers",
|
"display.terraforged.rivers.primary_rivers": "Primary Rivers",
|
||||||
"display.terraforged.rivers.primary_rivers.bank_width": "Bank Width",
|
"display.terraforged.rivers.primary_rivers.bank_width": "Bank Width",
|
||||||
@ -112,6 +129,7 @@
|
|||||||
"display.terraforged.structures.strongholds": "Strongholds",
|
"display.terraforged.structures.strongholds": "Strongholds",
|
||||||
"display.terraforged.structures.strongholds.distance": "Distance",
|
"display.terraforged.structures.strongholds.distance": "Distance",
|
||||||
"display.terraforged.structures.strongholds.separation": "Separation",
|
"display.terraforged.structures.strongholds.separation": "Separation",
|
||||||
|
"display.terraforged.structures.title": "Structure Settings",
|
||||||
"display.terraforged.structures.villages": "Villages",
|
"display.terraforged.structures.villages": "Villages",
|
||||||
"display.terraforged.structures.villages.distance": "Distance",
|
"display.terraforged.structures.villages.distance": "Distance",
|
||||||
"display.terraforged.structures.villages.separation": "Separation",
|
"display.terraforged.structures.villages.separation": "Separation",
|
||||||
@ -155,6 +173,7 @@
|
|||||||
"display.terraforged.terrain.steppe.horizontal_scale": "Horizontal Scale",
|
"display.terraforged.terrain.steppe.horizontal_scale": "Horizontal Scale",
|
||||||
"display.terraforged.terrain.steppe.vertical_scale": "Vertical Scale",
|
"display.terraforged.terrain.steppe.vertical_scale": "Vertical Scale",
|
||||||
"display.terraforged.terrain.steppe.weight": "Weight",
|
"display.terraforged.terrain.steppe.weight": "Weight",
|
||||||
|
"display.terraforged.terrain.title": "Terrain Settings",
|
||||||
"display.terraforged.terrain.torridonian": "Torridonian",
|
"display.terraforged.terrain.torridonian": "Torridonian",
|
||||||
"display.terraforged.terrain.torridonian.base_scale": "Base Scale",
|
"display.terraforged.terrain.torridonian.base_scale": "Base Scale",
|
||||||
"display.terraforged.terrain.torridonian.horizontal_scale": "Horizontal Scale",
|
"display.terraforged.terrain.torridonian.horizontal_scale": "Horizontal Scale",
|
||||||
@ -175,6 +194,7 @@
|
|||||||
"display.terraforged.world.properties.sea_level": "Sea Level",
|
"display.terraforged.world.properties.sea_level": "Sea Level",
|
||||||
"display.terraforged.world.properties.spawn_type": "Spawn Type",
|
"display.terraforged.world.properties.spawn_type": "Spawn Type",
|
||||||
"display.terraforged.world.properties.world_height": "World Height",
|
"display.terraforged.world.properties.world_height": "World Height",
|
||||||
|
"display.terraforged.world.title": "World Settings",
|
||||||
"display.terraforged.world.transition_points": "Transition Points",
|
"display.terraforged.world.transition_points": "Transition Points",
|
||||||
"display.terraforged.world.transition_points.beach": "Beach",
|
"display.terraforged.world.transition_points.beach": "Beach",
|
||||||
"display.terraforged.world.transition_points.coast": "Coast",
|
"display.terraforged.world.transition_points.coast": "Coast",
|
||||||
|
@ -8,8 +8,6 @@ import com.terraforged.Log;
|
|||||||
import com.terraforged.util.nbt.NBTHelper;
|
import com.terraforged.util.nbt.NBTHelper;
|
||||||
import net.minecraft.nbt.CompoundNBT;
|
import net.minecraft.nbt.CompoundNBT;
|
||||||
import net.minecraft.world.storage.WorldInfo;
|
import net.minecraft.world.storage.WorldInfo;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
|
||||||
import net.minecraftforge.fml.DistExecutor;
|
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.BufferedWriter;
|
import java.io.BufferedWriter;
|
||||||
@ -19,17 +17,16 @@ import java.io.FileWriter;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.Reader;
|
import java.io.Reader;
|
||||||
import java.io.Writer;
|
import java.io.Writer;
|
||||||
import java.nio.file.Files;
|
|
||||||
|
|
||||||
public class SettingsHelper {
|
public class SettingsHelper {
|
||||||
|
|
||||||
public static final String SETTINGS_FILE_NAME = "terraforged-generator.json";
|
|
||||||
public static final File SETTINGS_DIR = new File("config", "terraforged");
|
public static final File SETTINGS_DIR = new File("config", "terraforged");
|
||||||
public static final File SETTINGS_FILE= new File(SETTINGS_DIR, SETTINGS_FILE_NAME);
|
public static final File DEFAULTS_FILE = new File(SETTINGS_DIR, "generator-defaults.json");
|
||||||
|
|
||||||
private static final Gson GSON = new GsonBuilder().setPrettyPrinting().create();
|
private static final Gson GSON = new GsonBuilder().setPrettyPrinting().create();
|
||||||
|
|
||||||
public static void clearDefaults() {
|
public static void clearDefaults() {
|
||||||
if (SETTINGS_FILE.exists() && SETTINGS_FILE.delete()) {
|
if (DEFAULTS_FILE.exists() && DEFAULTS_FILE.delete()) {
|
||||||
Log.info("Deleted generator defaults");
|
Log.info("Deleted generator defaults");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -37,7 +34,7 @@ public class SettingsHelper {
|
|||||||
public static void exportDefaults(TerraSettings settings) {
|
public static void exportDefaults(TerraSettings settings) {
|
||||||
CompoundNBT tag = NBTHelper.serializeCompact(settings);
|
CompoundNBT tag = NBTHelper.serializeCompact(settings);
|
||||||
JsonElement json = NBTHelper.toJson(tag);
|
JsonElement json = NBTHelper.toJson(tag);
|
||||||
try (Writer writer = new BufferedWriter(new FileWriter(SETTINGS_FILE))) {
|
try (Writer writer = new BufferedWriter(new FileWriter(DEFAULTS_FILE))) {
|
||||||
GSON.toJson(json, writer);
|
GSON.toJson(json, writer);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@ -46,7 +43,7 @@ public class SettingsHelper {
|
|||||||
|
|
||||||
public static CompoundNBT applyDefaults(CompoundNBT options, TerraSettings dest) {
|
public static CompoundNBT applyDefaults(CompoundNBT options, TerraSettings dest) {
|
||||||
if (options.isEmpty()) {
|
if (options.isEmpty()) {
|
||||||
try (Reader reader = new BufferedReader(new FileReader(SETTINGS_FILE))) {
|
try (Reader reader = new BufferedReader(new FileReader(DEFAULTS_FILE))) {
|
||||||
JsonElement json = new JsonParser().parse(reader);
|
JsonElement json = new JsonParser().parse(reader);
|
||||||
options = NBTHelper.fromJson(json);
|
options = NBTHelper.fromJson(json);
|
||||||
} catch (IOException ignored) {
|
} catch (IOException ignored) {
|
||||||
@ -60,8 +57,8 @@ public class SettingsHelper {
|
|||||||
public static TerraSettings getSettings(WorldInfo info) {
|
public static TerraSettings getSettings(WorldInfo info) {
|
||||||
TerraSettings settings = new TerraSettings();
|
TerraSettings settings = new TerraSettings();
|
||||||
if (info.getGeneratorOptions().isEmpty()) {
|
if (info.getGeneratorOptions().isEmpty()) {
|
||||||
if (SETTINGS_FILE.exists()) {
|
if (DEFAULTS_FILE.exists()) {
|
||||||
try (Reader reader = new BufferedReader(new FileReader(SETTINGS_FILE))) {
|
try (Reader reader = new BufferedReader(new FileReader(DEFAULTS_FILE))) {
|
||||||
Log.info("Loading generator settings from json");
|
Log.info("Loading generator settings from json");
|
||||||
JsonElement json = new JsonParser().parse(reader);
|
JsonElement json = new JsonParser().parse(reader);
|
||||||
CompoundNBT root = NBTHelper.fromJson(json);
|
CompoundNBT root = NBTHelper.fromJson(json);
|
||||||
@ -78,24 +75,8 @@ public class SettingsHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void init() {
|
public static void init() {
|
||||||
if (SETTINGS_FILE.exists()) {
|
if (!DEFAULTS_FILE.exists()) {
|
||||||
return;
|
exportDefaults(new TerraSettings());
|
||||||
}
|
|
||||||
|
|
||||||
File src = new File("config", SETTINGS_FILE_NAME);
|
|
||||||
if (src.exists()) {
|
|
||||||
if (SETTINGS_DIR.exists() || SETTINGS_DIR.mkdirs()) {
|
|
||||||
try {
|
|
||||||
Files.copy(src.toPath(), SETTINGS_FILE.toPath());
|
|
||||||
if (src.delete()) {
|
|
||||||
Log.info("Moved settings file to new location: {}", SETTINGS_FILE.getAbsoluteFile());
|
|
||||||
}
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
DistExecutor.runWhenOn(Dist.DEDICATED_SERVER, () -> () -> exportDefaults(new TerraSettings()));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,9 @@ package com.terraforged.data;
|
|||||||
|
|
||||||
import com.terraforged.chunk.settings.TerraSettings;
|
import com.terraforged.chunk.settings.TerraSettings;
|
||||||
import com.terraforged.core.util.NameUtil;
|
import com.terraforged.core.util.NameUtil;
|
||||||
|
import com.terraforged.gui.GuiKeys;
|
||||||
import com.terraforged.gui.preview2.PreviewSettings;
|
import com.terraforged.gui.preview2.PreviewSettings;
|
||||||
|
import com.terraforged.util.TranslationKey;
|
||||||
import com.terraforged.util.nbt.NBTHelper;
|
import com.terraforged.util.nbt.NBTHelper;
|
||||||
import net.minecraft.nbt.CompoundNBT;
|
import net.minecraft.nbt.CompoundNBT;
|
||||||
import net.minecraft.nbt.INBT;
|
import net.minecraft.nbt.INBT;
|
||||||
@ -21,14 +23,18 @@ public class LangGenerator {
|
|||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public static void gather(GatherDataEvent event) {
|
public static void gather(GatherDataEvent event) {
|
||||||
|
GuiKeys.init();
|
||||||
|
|
||||||
LanguageProvider langProvider = new LanguageProvider(event.getGenerator(), "terraforged", "en_us") {
|
LanguageProvider langProvider = new LanguageProvider(event.getGenerator(), "terraforged", "en_us") {
|
||||||
@Override
|
@Override
|
||||||
protected void addTranslations() {
|
protected void addTranslations() {
|
||||||
worlds(this);
|
worlds(this);
|
||||||
biomes(this);
|
biomes(this);
|
||||||
|
translationKeys(this);
|
||||||
settings(this);
|
settings(this);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
event.getGenerator().addProvider(langProvider);
|
event.getGenerator().addProvider(langProvider);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -46,6 +52,10 @@ public class LangGenerator {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void translationKeys(LanguageProvider provider) {
|
||||||
|
TranslationKey.each(key -> provider.add(key.getKey(), key.getDefaultValue()));
|
||||||
|
}
|
||||||
|
|
||||||
private static void settings(LanguageProvider provider) {
|
private static void settings(LanguageProvider provider) {
|
||||||
visit(NBTHelper.serialize(new DataGenSettings()), provider);
|
visit(NBTHelper.serialize(new DataGenSettings()), provider);
|
||||||
}
|
}
|
||||||
|
34
src/main/java/com/terraforged/gui/GuiKeys.java
Normal file
34
src/main/java/com/terraforged/gui/GuiKeys.java
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
package com.terraforged.gui;
|
||||||
|
|
||||||
|
import com.terraforged.util.TranslationKey;
|
||||||
|
|
||||||
|
public class GuiKeys {
|
||||||
|
|
||||||
|
public static final TranslationKey DONE = TranslationKey.gui("general.done", "Done");
|
||||||
|
public static final TranslationKey CANCEL = TranslationKey.gui("general.cancel", "Cancel");
|
||||||
|
|
||||||
|
public static final TranslationKey PREVIEW_SEED = TranslationKey.gui("preview.seed", "New Seed");
|
||||||
|
public static final TranslationKey PREVIEW_AREA = TranslationKey.gui("preview.area", "Area: ");
|
||||||
|
public static final TranslationKey PREVIEW_TERRAIN = TranslationKey.gui("preview.terrain", "Terrain: ");
|
||||||
|
public static final TranslationKey PREVIEW_BIOME = TranslationKey.gui("preview.biome", "Biome: ");
|
||||||
|
|
||||||
|
public static final TranslationKey PRESETS = TranslationKey.gui("presets.title", "Presets & Defaults");
|
||||||
|
public static final TranslationKey WORLD_SETTINGS = TranslationKey.gui("world.title", "World Settings");
|
||||||
|
public static final TranslationKey CLIMATE_SETTINGS = TranslationKey.gui("climate.title", "Climate Settings");
|
||||||
|
public static final TranslationKey TERRAIN_SETTINGS = TranslationKey.gui("terrain.title", "Terrain Settings");
|
||||||
|
public static final TranslationKey RIVER_SETTINGS = TranslationKey.gui("river.title", "River Settings");
|
||||||
|
public static final TranslationKey FILTER_SETTINGS = TranslationKey.gui("filters.title", "Filter Settings");
|
||||||
|
public static final TranslationKey STRUCTURE_SETTINGS = TranslationKey.gui("structures.title", "Structure Settings");
|
||||||
|
public static final TranslationKey MISC_SETTINGS = TranslationKey.gui("miscellaneous.title", "Miscellaneous Settings");
|
||||||
|
|
||||||
|
public static final TranslationKey PRESET_CREATE = TranslationKey.gui("preset.create", "Create");
|
||||||
|
public static final TranslationKey PRESET_LOAD = TranslationKey.gui("preset.load", "Load");
|
||||||
|
public static final TranslationKey PRESET_SAVE = TranslationKey.gui("preset.save", "Save");
|
||||||
|
public static final TranslationKey PRESET_RESET = TranslationKey.gui("preset.reset", "Reset");
|
||||||
|
public static final TranslationKey PRESET_DEFAULT = TranslationKey.gui("preset.default", "Make Default");
|
||||||
|
public static final TranslationKey PRESET_DELETE = TranslationKey.gui("preset.delete", "Delete");
|
||||||
|
|
||||||
|
public static void init() {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -63,12 +63,12 @@ public class SettingsScreen extends OverlayScreen {
|
|||||||
this.pages = new Page[]{
|
this.pages = new Page[]{
|
||||||
new PresetsPage(instance, preview, preview.getPreviewWidget()),
|
new PresetsPage(instance, preview, preview.getPreviewWidget()),
|
||||||
new WorldPage(instance, preview),
|
new WorldPage(instance, preview),
|
||||||
new SimplePreviewPage("Climate Settings", "climate", preview, instance, s -> s.climate),
|
new SimplePreviewPage(GuiKeys.CLIMATE_SETTINGS, "climate", preview, instance, s -> s.climate),
|
||||||
new SimplePreviewPage("Terrain Settings", "terrain", preview, instance, s -> s.terrain),
|
new SimplePreviewPage(GuiKeys.TERRAIN_SETTINGS, "terrain", preview, instance, s -> s.terrain),
|
||||||
new SimplePreviewPage("River Settings", "rivers", preview, instance, s -> s.rivers),
|
new SimplePreviewPage(GuiKeys.RIVER_SETTINGS, "rivers", preview, instance, s -> s.rivers),
|
||||||
new SimplePreviewPage("Filter Settings", "filters", preview, instance, s -> s.filters),
|
new SimplePreviewPage(GuiKeys.FILTER_SETTINGS, "filters", preview, instance, s -> s.filters),
|
||||||
new SimplePage("Structure Settings", "structures", instance, s -> s.structures),
|
new SimplePage(GuiKeys.STRUCTURE_SETTINGS, "structures", instance, s -> s.structures),
|
||||||
new SimplePage("Feature Settings", "miscellaneous", instance, s -> s.miscellaneous)
|
new SimplePage(GuiKeys.MISC_SETTINGS, "miscellaneous", instance, s -> s.miscellaneous)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -104,10 +104,10 @@ public class SettingsScreen extends OverlayScreen {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// -52
|
// -52
|
||||||
addButton(new Button(buttonsCenter - buttonWidth - buttonPad, buttonsRow, buttonWidth, buttonHeight, "Cancel", b -> onClose()));
|
addButton(new Button(buttonsCenter - buttonWidth - buttonPad, buttonsRow, buttonWidth, buttonHeight, GuiKeys.CANCEL.get(), b -> onClose()));
|
||||||
|
|
||||||
// +2
|
// +2
|
||||||
addButton(new Button(buttonsCenter + buttonPad, buttonsRow, buttonWidth, buttonHeight, "Done", b -> {
|
addButton(new Button(buttonsCenter + buttonPad, buttonsRow, buttonWidth, buttonHeight, GuiKeys.DONE.get(), b -> {
|
||||||
for (Page page : pages) {
|
for (Page page : pages) {
|
||||||
page.save();
|
page.save();
|
||||||
}
|
}
|
||||||
@ -179,7 +179,7 @@ public class SettingsScreen extends OverlayScreen {
|
|||||||
boolean a = pages[pageIndex].action(pane -> pane.mouseClicked(x, y, button));
|
boolean a = pages[pageIndex].action(pane -> pane.mouseClicked(x, y, button));
|
||||||
boolean b = isPresetsPage() || preview.action(pane -> pane.mouseClicked(x, y, button));;
|
boolean b = isPresetsPage() || preview.action(pane -> pane.mouseClicked(x, y, button));;
|
||||||
boolean c = super.mouseClicked(x, y, button);
|
boolean c = super.mouseClicked(x, y, button);
|
||||||
return a || b || c || true;
|
return a || b || c;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -187,7 +187,7 @@ public class SettingsScreen extends OverlayScreen {
|
|||||||
boolean a = pages[pageIndex].action(pane -> pane.mouseReleased(x, y, button));
|
boolean a = pages[pageIndex].action(pane -> pane.mouseReleased(x, y, button));
|
||||||
boolean b = isPresetsPage() || preview.action(pane -> pane.mouseReleased(x, y, button));
|
boolean b = isPresetsPage() || preview.action(pane -> pane.mouseReleased(x, y, button));
|
||||||
boolean c = super.mouseReleased(x, y, button);
|
boolean c = super.mouseReleased(x, y, button);
|
||||||
return a || b || c || true;
|
return a || b || c;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
package com.terraforged.gui.page;
|
package com.terraforged.gui.page;
|
||||||
|
|
||||||
|
import com.terraforged.chunk.settings.SettingsHelper;
|
||||||
import com.terraforged.chunk.settings.TerraSettings;
|
import com.terraforged.chunk.settings.TerraSettings;
|
||||||
import com.terraforged.chunk.settings.preset.Preset;
|
import com.terraforged.chunk.settings.preset.Preset;
|
||||||
import com.terraforged.chunk.settings.preset.PresetManager;
|
import com.terraforged.chunk.settings.preset.PresetManager;
|
||||||
|
import com.terraforged.gui.GuiKeys;
|
||||||
import com.terraforged.gui.Instance;
|
import com.terraforged.gui.Instance;
|
||||||
import com.terraforged.gui.OverlayScreen;
|
import com.terraforged.gui.OverlayScreen;
|
||||||
import com.terraforged.gui.ScrollPane;
|
import com.terraforged.gui.ScrollPane;
|
||||||
@ -39,7 +41,7 @@ public class PresetsPage extends BasePage {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getTitle() {
|
public String getTitle() {
|
||||||
return "Presets & Defaults";
|
return GuiKeys.PRESETS.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -63,7 +65,7 @@ public class PresetsPage extends BasePage {
|
|||||||
Column right = getColumn(1);
|
Column right = getColumn(1);
|
||||||
right.scrollPane.addButton(nameInput);
|
right.scrollPane.addButton(nameInput);
|
||||||
|
|
||||||
right.scrollPane.addButton(new TerraButton("Create") {
|
right.scrollPane.addButton(new TerraButton(GuiKeys.PRESET_CREATE.get()) {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(int x, int z, float ticks) {
|
public void render(int x, int z, float ticks) {
|
||||||
@ -91,7 +93,7 @@ public class PresetsPage extends BasePage {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
right.scrollPane.addButton(new TerraButton("Load") {
|
right.scrollPane.addButton(new TerraButton(GuiKeys.PRESET_LOAD.get()) {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(int x, int z, float ticks) {
|
public void render(int x, int z, float ticks) {
|
||||||
@ -106,7 +108,7 @@ public class PresetsPage extends BasePage {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
right.scrollPane.addButton(new TerraButton("Save") {
|
right.scrollPane.addButton(new TerraButton(GuiKeys.PRESET_SAVE.get()) {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(int x, int z, float ticks) {
|
public void render(int x, int z, float ticks) {
|
||||||
@ -131,7 +133,7 @@ public class PresetsPage extends BasePage {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
right.scrollPane.addButton(new TerraButton("Reset") {
|
right.scrollPane.addButton(new TerraButton(GuiKeys.PRESET_RESET.get()) {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(int x, int z, float ticks) {
|
public void render(int x, int z, float ticks) {
|
||||||
@ -155,7 +157,26 @@ public class PresetsPage extends BasePage {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
right.scrollPane.addButton(new TerraButton("Delete") {
|
right.scrollPane.addButton(new TerraButton(GuiKeys.PRESET_DEFAULT.get()) {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void render(int x, int z, float ticks) {
|
||||||
|
super.active = hasSelectedPreset();
|
||||||
|
super.render(x, z, ticks);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(double x, double y) {
|
||||||
|
super.onClick(x, y);
|
||||||
|
getSelected().ifPresent(preset -> {
|
||||||
|
TerraSettings settings = preset.getSettings();
|
||||||
|
|
||||||
|
SettingsHelper.exportDefaults(settings);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
right.scrollPane.addButton(new TerraButton(GuiKeys.PRESET_DELETE.get()) {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(int x, int z, float ticks) {
|
public void render(int x, int z, float ticks) {
|
||||||
|
@ -3,6 +3,7 @@ package com.terraforged.gui.page;
|
|||||||
import com.terraforged.chunk.settings.TerraSettings;
|
import com.terraforged.chunk.settings.TerraSettings;
|
||||||
import com.terraforged.gui.Instance;
|
import com.terraforged.gui.Instance;
|
||||||
import com.terraforged.gui.OverlayScreen;
|
import com.terraforged.gui.OverlayScreen;
|
||||||
|
import com.terraforged.util.TranslationKey;
|
||||||
import net.minecraft.nbt.CompoundNBT;
|
import net.minecraft.nbt.CompoundNBT;
|
||||||
|
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
@ -16,8 +17,8 @@ public class SimplePage extends BasePage {
|
|||||||
|
|
||||||
protected CompoundNBT sectionSettings = null;
|
protected CompoundNBT sectionSettings = null;
|
||||||
|
|
||||||
public SimplePage(String title, String sectionName, Instance instance, Function<TerraSettings, Object> section) {
|
public SimplePage(TranslationKey title, String sectionName, Instance instance, Function<TerraSettings, Object> section) {
|
||||||
this.title = title;
|
this.title = title.get();
|
||||||
this.section = section;
|
this.section = section;
|
||||||
this.sectionName = sectionName;
|
this.sectionName = sectionName;
|
||||||
this.instance = instance;
|
this.instance = instance;
|
||||||
|
@ -2,6 +2,7 @@ package com.terraforged.gui.page;
|
|||||||
|
|
||||||
import com.terraforged.chunk.settings.TerraSettings;
|
import com.terraforged.chunk.settings.TerraSettings;
|
||||||
import com.terraforged.gui.Instance;
|
import com.terraforged.gui.Instance;
|
||||||
|
import com.terraforged.util.TranslationKey;
|
||||||
import com.terraforged.util.nbt.NBTHelper;
|
import com.terraforged.util.nbt.NBTHelper;
|
||||||
|
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
@ -10,7 +11,7 @@ public class SimplePreviewPage extends SimplePage {
|
|||||||
|
|
||||||
private final UpdatablePage preview;
|
private final UpdatablePage preview;
|
||||||
|
|
||||||
public SimplePreviewPage(String title, String sectionName, UpdatablePage preview, Instance instance, Function<TerraSettings, Object> section) {
|
public SimplePreviewPage(TranslationKey title, String sectionName, UpdatablePage preview, Instance instance, Function<TerraSettings, Object> section) {
|
||||||
super(title, sectionName, instance, section);
|
super(title, sectionName, instance, section);
|
||||||
this.preview = preview;
|
this.preview = preview;
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
package com.terraforged.gui.page;
|
package com.terraforged.gui.page;
|
||||||
|
|
||||||
import com.terraforged.TerraWorld;
|
import com.terraforged.TerraWorld;
|
||||||
|
import com.terraforged.gui.GuiKeys;
|
||||||
import com.terraforged.gui.Instance;
|
import com.terraforged.gui.Instance;
|
||||||
import com.terraforged.gui.OverlayScreen;
|
import com.terraforged.gui.OverlayScreen;
|
||||||
import com.terraforged.gui.element.TerraTextInput;
|
import com.terraforged.gui.element.TerraTextInput;
|
||||||
@ -53,7 +54,7 @@ public class WorldPage extends BasePage {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getTitle() {
|
public String getTitle() {
|
||||||
return "World Settings";
|
return GuiKeys.WORLD_SETTINGS.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -34,6 +34,7 @@ import com.terraforged.core.settings.Settings;
|
|||||||
import com.terraforged.core.tile.Size;
|
import com.terraforged.core.tile.Size;
|
||||||
import com.terraforged.core.tile.Tile;
|
import com.terraforged.core.tile.Tile;
|
||||||
import com.terraforged.core.tile.gen.TileGenerator;
|
import com.terraforged.core.tile.gen.TileGenerator;
|
||||||
|
import com.terraforged.gui.GuiKeys;
|
||||||
import com.terraforged.n2d.util.NoiseUtil;
|
import com.terraforged.n2d.util.NoiseUtil;
|
||||||
import com.terraforged.util.nbt.NBTHelper;
|
import com.terraforged.util.nbt.NBTHelper;
|
||||||
import com.terraforged.world.GeneratorContext;
|
import com.terraforged.world.GeneratorContext;
|
||||||
@ -71,7 +72,7 @@ public class Preview extends Button {
|
|||||||
private CacheEntry<Tile> task = null;
|
private CacheEntry<Tile> task = null;
|
||||||
private Tile tile = null;
|
private Tile tile = null;
|
||||||
|
|
||||||
private String[] labels = {"Area: ", "Terrain: ", "Biome: "};
|
private String[] labels = {GuiKeys.PREVIEW_AREA.get(), GuiKeys.PREVIEW_TERRAIN.get(), GuiKeys.PREVIEW_BIOME.get()};
|
||||||
private String[] values = {"", "", ""};
|
private String[] values = {"", "", ""};
|
||||||
|
|
||||||
public Preview(int seed) {
|
public Preview(int seed) {
|
||||||
@ -276,11 +277,10 @@ public class Preview extends Button {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static String getTerrainName(Cell cell) {
|
private static String getTerrainName(Cell cell) {
|
||||||
String terrain = cell.terrain.getName().toLowerCase();
|
if (cell.terrain.isRiver()) {
|
||||||
if (terrain.contains("river")) {
|
|
||||||
return "river";
|
return "river";
|
||||||
}
|
}
|
||||||
return terrain;
|
return cell.terrain.getName().toLowerCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String getBiomeName(Cell cell) {
|
private static String getBiomeName(Cell cell) {
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
package com.terraforged.gui.preview;
|
package com.terraforged.gui.preview;
|
||||||
|
|
||||||
import com.terraforged.chunk.settings.TerraSettings;
|
import com.terraforged.chunk.settings.TerraSettings;
|
||||||
|
import com.terraforged.gui.GuiKeys;
|
||||||
import com.terraforged.gui.OverlayScreen;
|
import com.terraforged.gui.OverlayScreen;
|
||||||
import com.terraforged.gui.element.TerraButton;
|
import com.terraforged.gui.element.TerraButton;
|
||||||
import com.terraforged.gui.page.UpdatablePage;
|
import com.terraforged.gui.page.UpdatablePage;
|
||||||
@ -73,7 +74,7 @@ public class PreviewPage extends UpdatablePage {
|
|||||||
preview.setHeight(Preview.HEIGHT);
|
preview.setHeight(Preview.HEIGHT);
|
||||||
|
|
||||||
addElements(right.left, right.top, right, previewerSettings, right.scrollPane::addButton, this::update);
|
addElements(right.left, right.top, right, previewerSettings, right.scrollPane::addButton, this::update);
|
||||||
right.scrollPane.addButton(new TerraButton("New Seed") {
|
right.scrollPane.addButton(new TerraButton(GuiKeys.PREVIEW_SEED.get()) {
|
||||||
@Override
|
@Override
|
||||||
public void onPress() {
|
public void onPress() {
|
||||||
preview.regenerate();
|
preview.regenerate();
|
||||||
|
59
src/main/java/com/terraforged/util/TranslationKey.java
Normal file
59
src/main/java/com/terraforged/util/TranslationKey.java
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
package com.terraforged.util;
|
||||||
|
|
||||||
|
import com.terraforged.core.util.NameUtil;
|
||||||
|
import net.minecraft.client.resources.I18n;
|
||||||
|
|
||||||
|
import java.util.Comparator;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
|
public class TranslationKey {
|
||||||
|
|
||||||
|
private static final Map<String, TranslationKey> keys = new HashMap<>();
|
||||||
|
|
||||||
|
private final String translationKey;
|
||||||
|
private final String defaultValue;
|
||||||
|
|
||||||
|
public TranslationKey(String key, String display) {
|
||||||
|
this.translationKey = key;
|
||||||
|
this.defaultValue = display;
|
||||||
|
keys.put(translationKey, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getKey() {
|
||||||
|
return translationKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDefaultValue() {
|
||||||
|
return defaultValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String get() {
|
||||||
|
if (I18n.hasKey(translationKey)) {
|
||||||
|
return I18n.format(translationKey);
|
||||||
|
}
|
||||||
|
return defaultValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String get(Object... args) {
|
||||||
|
if (I18n.hasKey(translationKey)) {
|
||||||
|
return I18n.format(translationKey, args);
|
||||||
|
}
|
||||||
|
return defaultValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void each(Consumer<TranslationKey> consumer) {
|
||||||
|
keys.values().stream().sorted(Comparator.comparing(TranslationKey::getKey)).forEach(consumer);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static TranslationKey gui(String text) {
|
||||||
|
String key = NameUtil.toDisplayNameKey(text);
|
||||||
|
String display = NameUtil.toDisplayName(text.substring(text.lastIndexOf('.') + 1));
|
||||||
|
return new TranslationKey(key, display);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static TranslationKey gui(String key, String display) {
|
||||||
|
return new TranslationKey(NameUtil.toDisplayNameKey(key), display);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user