Added a debug option to override the player's size

This commit is contained in:
Sollace 2019-06-05 15:42:20 +02:00
parent f3f980d6c3
commit 916b3b11e0
4 changed files with 41 additions and 8 deletions

View file

@ -13,6 +13,7 @@ import com.minelittlepony.common.client.gui.element.Button;
import com.minelittlepony.common.client.gui.element.Label;
import com.minelittlepony.common.client.gui.element.Slider;
import com.minelittlepony.common.client.gui.element.Toggle;
import com.minelittlepony.pony.meta.Size;
import com.minelittlepony.settings.PonyConfig;
import com.minelittlepony.settings.PonyLevel;
import com.minelittlepony.settings.PonySettings;
@ -89,11 +90,12 @@ public class GuiPonySettings extends GameGui {
if (hiddenOptions) {
content.addButton(new Label(LEFT, row += 30)).getStyle().setText("minelp.debug.scale");
content.addButton(new Slider(LEFT, row += 15, 0.1F, 3, config.getGlobalScaleFactor())
.onChange(v -> {
config.setGlobalScaleFactor(v);
return config.getGlobalScaleFactor();
})
.onChange(config::setGlobalScaleFactor)
.setFormatter(value -> I18n.translate("minelp.debug.scale.value", I18n.translate(describeCurrentScale(value)))));
content.addButton(new Label(LEFT, row += 30)).getStyle().setText("minelp.debug.size");
content.addButton(new Slider(LEFT, row += 15, 0, Size.REGISTRY.length - 1, config.getOverrideSize().ordinal())
.onChange(config::setSizeOverride)
.setFormatter(value -> value < Size.REGISTRY.length ? Size.REGISTRY[(int)(float)value].name() : "Unset"));
}
row += 20;

View file

@ -10,7 +10,10 @@ public enum Size implements ITriggerPixelMapped<Size> {
LANKY (0xce5432, 0.45F, 0.85F, 0.9F),
NORMAL (0x000000, 0.4f, 0.8F, 0.8F),
YEARLING(0xffbe53, 0.4F, 0.6F, 0.65F),
FOAL (0x53beff, 0.25f, 0.6F, 0.5F);
FOAL (0x53beff, 0.25f, 0.6F, 0.5F),
UNSET (0x000000, 1, 1, 1);
public static final Size[] REGISTRY = values();
private int triggerValue;
@ -53,6 +56,16 @@ public enum Size implements ITriggerPixelMapped<Size> {
}
public Size getEffectiveSize() {
return PonySettings.SIZES.get() ? this : Size.NORMAL;
Size sz = MineLittlePony.getInstance().getConfig().getOverrideSize();
if (sz != UNSET) {
return sz;
}
if (this == UNSET || !PonySettings.SIZES.get()) {
return NORMAL;
}
return this;
}
}

View file

@ -2,6 +2,8 @@ package com.minelittlepony.settings;
import net.minecraft.util.math.MathHelper;
import com.minelittlepony.pony.meta.Size;
/**
* Storage container for MineLP client settings.
*/
@ -9,6 +11,7 @@ public class PonyConfig extends JsonConfig {
private final Setting<PonyLevel> ponyLevel = new Value<>("ponylevel", PonyLevel.PONIES);
private final Setting<Float> scaleFactor = new Value<>("globalScaleFactor", 0.9F);
private final Setting<Size> sizeOverride = new Value<>("sieOverride", Size.UNSET);
public PonyConfig() {
initWith(PonySettings.values());
@ -39,11 +42,13 @@ public class PonyConfig extends JsonConfig {
ponyLevel.set(ponylevel);
}
public void setGlobalScaleFactor(float f) {
public float setGlobalScaleFactor(float f) {
f = Math.round(MathHelper.clamp(f, 0.1F, 3) * 100) / 100F;
scaleFactor.set(f);
PonySettings.SHOWSCALE.set(f != 1);
return getGlobalScaleFactor();
}
/**
@ -52,4 +57,16 @@ public class PonyConfig extends JsonConfig {
public float getGlobalScaleFactor() {
return PonySettings.SHOWSCALE.get() ? scaleFactor.get() : 1;
}
public Size getOverrideSize() {
return sizeOverride.get();
}
public float setSizeOverride(float value) {
value = Math.round(value);
Size size = Size.REGISTRY[(int) value % Size.REGISTRY.length];
sizeOverride.set(size);
return size.ordinal();
}
}

View file

@ -31,5 +31,6 @@
"minelp.debug.scale.max": "Double",
"minelp.debug.scale.mid": "Default",
"minelp.debug.scale.sa": "Show Accurate",
"minelp.debug.scale.min": "Miniscule"
"minelp.debug.scale.min": "Miniscule",
"minelp.debug.size": "Size Override"
}