improvements to transition sliders

This commit is contained in:
dags- 2020-06-29 18:27:02 +01:00
parent 058433173e
commit 95ffc7765f
11 changed files with 121 additions and 150 deletions

2
Engine

@ -1 +1 @@
Subproject commit ad79d9cb059d512a955e99bdd9a4340e07ae34e8
Subproject commit 37a553e45da72353eb608459b195e8f503a3fcab

View File

@ -1,106 +0,0 @@
{
"biome.terraforged.bryce": "Bryce",
"biome.terraforged.cold_steppe": "Cold Steppe",
"biome.terraforged.fir_forest": "Fir Forest",
"biome.terraforged.flower_plains": "Flower Plains",
"biome.terraforged.frozen_lake": "Frozen Lake",
"biome.terraforged.lake": "Lake",
"biome.terraforged.marshland": "Marshland",
"biome.terraforged.savanna_scrub": "Savanna Scrub",
"biome.terraforged.shattered_savanna_scrub": "Shattered Savanna Scrub",
"biome.terraforged.snowy_fir_forest": "Snowy Fir Forest",
"biome.terraforged.snowy_taiga_scrub": "Snowy Taiga Scrub",
"biome.terraforged.steppe": "Steppe",
"biome.terraforged.stone_forest": "Stone Forest",
"biome.terraforged.taiga_scrub": "Taiga Scrub",
"biome.terraforged.warm_beach": "Warm Beach",
"display.terraforged.climate.title": "Climate Settings",
"display.terraforged.dimensions": "Dimensions",
"display.terraforged.dimensions.bedrock_layer": "Bedrock Layer",
"display.terraforged.dimensions.bedrock_layer.material": "Material",
"display.terraforged.dimensions.bedrock_layer.min_depth": "Min Depth",
"display.terraforged.dimensions.bedrock_layer.variance": "Variance",
"display.terraforged.dimensions.dimensions": "Dimensions",
"display.terraforged.dimensions.dimensions.end": "End",
"display.terraforged.dimensions.dimensions.nether": "Nether",
"display.terraforged.filters.title": "Filter Settings",
"display.terraforged.general.cancel": "Cancel",
"display.terraforged.general.done": "Done",
"display.terraforged.miscellaneous": "Miscellaneous",
"display.terraforged.miscellaneous.custom_biome_features": "Custom Biome Features",
"display.terraforged.miscellaneous.erosion_decorator": "Erosion Decorator",
"display.terraforged.miscellaneous.mountain_biome_usage": "Mountain Biome Usage",
"display.terraforged.miscellaneous.natural_snow_decorator": "Natural Snow Decorator",
"display.terraforged.miscellaneous.smooth_layer_decorator": "Smooth Layer 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.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.area": "Area: ",
"display.terraforged.preview.biome": "Biome: ",
"display.terraforged.preview.display": "Display",
"display.terraforged.preview.seed": "New Seed",
"display.terraforged.preview.terrain": "Terrain: ",
"display.terraforged.preview.zoom": "Zoom",
"display.terraforged.river.title": "River Settings",
"display.terraforged.structures": "Structures",
"display.terraforged.structures.mansions": "Mansions",
"display.terraforged.structures.mansions.distance": "Distance",
"display.terraforged.structures.mansions.separation": "Separation",
"display.terraforged.structures.ocean_monuments": "Ocean Monuments",
"display.terraforged.structures.ocean_monuments.distance": "Distance",
"display.terraforged.structures.ocean_monuments.separation": "Separation",
"display.terraforged.structures.ocean_ruins": "Ocean Ruins",
"display.terraforged.structures.ocean_ruins.distance": "Distance",
"display.terraforged.structures.ocean_ruins.separation": "Separation",
"display.terraforged.structures.other_structures": "Other Structures",
"display.terraforged.structures.other_structures.distance": "Distance",
"display.terraforged.structures.other_structures.separation": "Separation",
"display.terraforged.structures.shipwrecks": "Shipwrecks",
"display.terraforged.structures.shipwrecks.distance": "Distance",
"display.terraforged.structures.shipwrecks.separation": "Separation",
"display.terraforged.structures.strongholds": "Strongholds",
"display.terraforged.structures.strongholds.distance": "Distance",
"display.terraforged.structures.strongholds.separation": "Separation",
"display.terraforged.structures.title": "Structure Settings",
"display.terraforged.structures.villages": "Villages",
"display.terraforged.structures.villages.distance": "Distance",
"display.terraforged.structures.villages.separation": "Separation",
"display.terraforged.terrain.title": "Terrain Settings",
"display.terraforged.world.title": "World Settings",
"generator.terraforged": "TerraForged",
"generator.terratest": "TerraTest",
"tooltip.terraforged.dimensions.bedrock_layer.material": "Controls the material that should be used in the world's base layer",
"tooltip.terraforged.dimensions.bedrock_layer.min_depth": "Controls the minimum height of the world's base layer",
"tooltip.terraforged.dimensions.bedrock_layer.variance": "Controls the amount of height randomness of the world's base layer",
"tooltip.terraforged.dimensions.dimensions.end": "Select the end generator",
"tooltip.terraforged.dimensions.dimensions.nether": "Select the nether generator",
"tooltip.terraforged.miscellaneous.custom_biome_features": "Use custom biome features in place of vanilla ones (such as trees)",
"tooltip.terraforged.miscellaneous.erosion_decorator": "Replace surface materials where erosion has occurred",
"tooltip.terraforged.miscellaneous.mountain_biome_usage": "The probability that mountainous terrain will be set to a mountain biome type.\nThis may help improve compatibility with mods that rely exclusively on mountain biomes.",
"tooltip.terraforged.miscellaneous.natural_snow_decorator": "Removes snow from the terrain where it shouldn't naturally settle",
"tooltip.terraforged.miscellaneous.smooth_layer_decorator": "Modifies layer block levels (ie snow) to fit the terrain",
"tooltip.terraforged.miscellaneous.strata_decorator": "Generates strata (rock layers) instead of just stone",
"tooltip.terraforged.miscellaneous.vanilla_water_features": "Controls whether vanilla lakes & springs should generate",
"tooltip.terraforged.structures.mansions.distance": "The maximum distance in chunks between attempts to spawn a structure",
"tooltip.terraforged.structures.mansions.separation": "The minimum distance in chunks between structure spawns",
"tooltip.terraforged.structures.ocean_monuments.distance": "The maximum distance in chunks between attempts to spawn a structure",
"tooltip.terraforged.structures.ocean_monuments.separation": "The minimum distance in chunks between structure spawns",
"tooltip.terraforged.structures.ocean_ruins.distance": "The maximum distance in chunks between attempts to spawn a structure",
"tooltip.terraforged.structures.ocean_ruins.separation": "The minimum distance in chunks between structure spawns",
"tooltip.terraforged.structures.other_structures.distance": "The maximum distance in chunks between attempts to spawn a structure",
"tooltip.terraforged.structures.other_structures.separation": "The minimum distance in chunks between structure spawns",
"tooltip.terraforged.structures.shipwrecks.distance": "The maximum distance in chunks between attempts to spawn a structure",
"tooltip.terraforged.structures.shipwrecks.separation": "The minimum distance in chunks between structure spawns",
"tooltip.terraforged.structures.strongholds.distance": "The maximum distance in chunks between attempts to spawn a structure",
"tooltip.terraforged.structures.strongholds.separation": "The minimum distance in chunks between structure spawns",
"tooltip.terraforged.structures.villages.distance": "The maximum distance in chunks between attempts to spawn a structure",
"tooltip.terraforged.structures.villages.separation": "The minimum distance in chunks between structure spawns"
}

View File

@ -20,7 +20,7 @@ public class BeachModifier implements BiomeModifier {
public BeachModifier(BiomeMap biomeMap, GeneratorContext context) {
this.biomes = biomeMap;
this.height = context.levels.water(6);
this.noise = Source.perlin(context.seed.next(), 10, 1).scale(context.levels.scale(5));
this.noise = Source.perlin(context.seed.next(), 15, 1).scale(context.levels.scale(5));
}
@Override

View File

@ -140,7 +140,7 @@ public class TerraChunkGenerator extends ChunkGenerator<GenerationSettings> {
@Override
public final void generateSurface(WorldGenRegion world, IChunk chunk) {
// surfaceGenerator.generateSurface(world, chunk);
surfaceGenerator.generateSurface(world, chunk);
}
@Override

View File

@ -25,8 +25,9 @@ public class GuiKeys {
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 final TranslationKey PRESET_SET_DEFAULTS = TranslationKey.gui("preset.default.set", "Make Defaults");
public static final TranslationKey PRESET_CLEAR_DEFAULTS = TranslationKey.gui("preset.default.reset", "Reset Defaults");
public static void init() {

View File

@ -0,0 +1,54 @@
package com.terraforged.mod.client.gui.element;
import com.terraforged.n2d.util.NoiseUtil;
import net.minecraft.nbt.CompoundNBT;
import net.minecraftforge.fml.client.gui.widget.Slider;
public class TerraBoundSlider extends TerraSlider.Float {
private final float pad;
private final String lower;
private final String upper;
public TerraBoundSlider(String name, CompoundNBT value) {
this(name, value, 0.01F);
}
public TerraBoundSlider(String name, CompoundNBT value, float pad) {
super(name, value);
CompoundNBT meta = value.getCompound("#" + name);
this.pad = pad;
this.lower = meta.getString("limit_lower");
this.upper = meta.getString("limit_upper");
}
@Override
protected void onChange(Slider slider, CompoundNBT value) {
int i = (int) (slider.getValue() * 1000);
float lower = getLower(value) + pad;
float upper = getUpper(value) - pad;
float val = NoiseUtil.clamp(i / 1000F, lower, upper);
// update setting value
value.putFloat(name, val);
// update actual slider value
setValue(val);
updateSlider();
}
private float getLower(CompoundNBT value) {
if (lower == null || lower.isEmpty()) {
return 0F;
}
return value.getFloat(lower);
}
private float getUpper(CompoundNBT value) {
if (upper == null || upper.isEmpty()) {
return 1F;
}
return value.getFloat(upper);
}
}

View File

@ -36,6 +36,7 @@ public abstract class TerraSlider extends Slider implements Slider.ISlider, Elem
private final CompoundNBT value;
private final List<String> tooltip;
private boolean lock = false;
private Runnable callback = () -> {};
public TerraSlider(String name, CompoundNBT value, boolean decimal) {
@ -58,7 +59,11 @@ public abstract class TerraSlider extends Slider implements Slider.ISlider, Elem
@Override
public void onChangeSliderValue(Slider slider) {
onChange(slider, value);
if (!lock) {
lock = true;
onChange(slider, value);
lock = false;
}
}
@Override

View File

@ -29,6 +29,7 @@ import com.terraforged.mod.client.gui.OverlayRenderer;
import com.terraforged.mod.client.gui.OverlayScreen;
import com.terraforged.mod.client.gui.ScrollPane;
import com.terraforged.mod.client.gui.element.Element;
import com.terraforged.mod.client.gui.element.TerraBoundSlider;
import com.terraforged.mod.client.gui.element.TerraLabel;
import com.terraforged.mod.client.gui.element.TerraSlider;
import com.terraforged.mod.client.gui.element.TerraTextInput;
@ -168,6 +169,8 @@ public abstract class Page implements IGuiEventListener, OverlayRenderer {
byte type = tag.getId();
if (type == Constants.NBT.TAG_INT) {
return new TerraSlider.Int(name, value).callback(callback);
} else if (type == Constants.NBT.TAG_FLOAT && hasLimit(name, value)) {
return new TerraBoundSlider(name, value).callback(callback);
} else if (type == Constants.NBT.TAG_FLOAT) {
return new TerraSlider.Float(name, value).callback(callback);
} else if (type == Constants.NBT.TAG_STRING && hasOptions(name, value)) {
@ -209,4 +212,8 @@ public abstract class Page implements IGuiEventListener, OverlayRenderer {
private static boolean hasOptions(String name, CompoundNBT value) {
return value.getCompound("#" + name).contains("options");
}
private static boolean hasLimit(String name, CompoundNBT value) {
return value.getCompound("#" + name).contains("limit_lower");
}
}

View File

@ -156,25 +156,6 @@ public class PresetsPage extends BasePage {
}
});
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
@ -194,6 +175,34 @@ public class PresetsPage extends BasePage {
}
});
right.scrollPane.addButton(new TerraButton(GuiKeys.PRESET_SET_DEFAULTS.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_CLEAR_DEFAULTS.get()) {
@Override
public void onClick(double x, double y) {
super.onClick(x, y);
TerraSettings settings = new TerraSettings();
SettingsHelper.exportDefaults(settings);
}
});
right.scrollPane.addButton(previewWidget);
// used to pad the scroll-pane out so that the preview legend scrolls on larger gui scales

View File

@ -70,6 +70,7 @@ public class WorldPage extends BasePage {
Column left = getColumn(0);
addElements(left.left, left.top, left, worldSettings, true, left.scrollPane::addButton, this::update);
addElements(left.left, left.top, left, dimSettings, true, left.scrollPane::addButton, this::update);
}

View File

@ -40,6 +40,26 @@ public enum RenderMode {
return rgba(hsb[0], hsb[1], (hsb[2] * scale) + bias);
}
},
TRANSITION_POINTS {
@Override
public int getColor(Cell cell, float scale, float bias) {
switch (cell.terrain.getType()) {
case DEEP_OCEAN:
return rgba(0.65F, 0.7F, 0.7F);
case SHALLOW_OCEAN:
return rgba(0.6F, 0.6F, 0.8F);
case BEACH:
return rgba(0.2F, 0.4F, 0.75F);
case COAST:
return rgba(0.35F, 0.75F, 0.65F);
default:
if (cell.terrain.isRiver() || cell.terrain.isWetland()) {
return rgba(0.6F, 0.6F, 0.8F);
}
return rgba(0.3F, 0.7F, 0.5F);
}
}
},
TEMPERATURE {
@Override
public int getColor(Cell cell, float scale, float bias) {
@ -80,26 +100,6 @@ public enum RenderMode {
return rgba(cell.region, saturation, brightness);
}
},
TRANSITION_POINTS {
@Override
public int getColor(Cell cell, float scale, float bias) {
switch (cell.terrain.getType()) {
case DEEP_OCEAN:
return rgba(0.65F, 0.7F, 0.7F);
case SHALLOW_OCEAN:
return rgba(0.6F, 0.6F, 0.8F);
case BEACH:
return rgba(0.2F, 0.4F, 0.75F);
case COAST:
return rgba(0.35F, 0.75F, 0.65F);
default:
if (cell.terrain.isRiver() || cell.terrain.isWetland()) {
return rgba(0.6F, 0.6F, 0.8F);
}
return rgba(0.3F, 0.7F, 0.5F);
}
}
}
;
public int getColor(Cell cell, Levels levels) {