Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package gigaherz.inventoryspam.config;
- import cpw.mods.fml.client.config.GuiSlider;
- public class ExponentialNumberSliderEntry extends cpw.mods.fml.client.config.GuiConfigEntries.ButtonEntry
- {
- protected final double beforeValue;
- public ExponentialNumberSliderEntry(cpw.mods.fml.client.config.GuiConfig owningScreen, cpw.mods.fml.client.config.GuiConfigEntries owningEntryList, cpw.mods.fml.client.config.IConfigElement configElement)
- {
- super(owningScreen, owningEntryList, configElement, new GuiExponentialSlider(0, 0, 0, 18, 10, "", "%",
- Double.valueOf(configElement.getMinValue().toString()).doubleValue(), Double.valueOf(configElement.getMaxValue().toString()).doubleValue(),
- Double.valueOf(configElement.get().toString()).doubleValue(), configElement.getType() == cpw.mods.fml.client.config.ConfigGuiType.DOUBLE, true));
- beforeValue = Double.valueOf(configElement.get().toString()).doubleValue();
- }
- public void updateValueButtonText()
- {
- ((GuiSlider)btnValue).updateSlider();
- }
- public void valueButtonPressed(int slotIndex) {}
- public boolean isDefault()
- {
- return ((GuiSlider)btnValue).getValue() == Double.valueOf(configElement.getDefault().toString()).doubleValue();
- }
- public void setToDefault()
- {
- if (enabled())
- {
- ((GuiSlider)btnValue).setValue(Double.valueOf(configElement.getDefault().toString()).doubleValue());
- ((GuiSlider)btnValue).updateSlider();
- }
- }
- public boolean isChanged()
- {
- return ((GuiSlider)btnValue).getValue() != beforeValue;
- }
- public void undoChanges()
- {
- if (enabled())
- {
- ((GuiSlider)btnValue).setValue(beforeValue);
- ((GuiSlider)btnValue).updateSlider();
- }
- }
- public boolean saveConfigElement()
- {
- if ((enabled()) && (isChanged()))
- {
- configElement.set(Double.valueOf(((GuiSlider)btnValue).getValue()));
- return configElement.requiresMcRestart();
- }
- return false;
- }
- public Object getCurrentValue()
- {
- return Double.valueOf(((GuiSlider)btnValue).getValue());
- }
- public Object[] getCurrentValues()
- {
- return new Object[] { getCurrentValue() };
- }
- private static class GuiExponentialSlider extends GuiSlider
- {
- public GuiExponentialSlider(int id, int xPos, int yPos, int width, int height, String prefix, String suf, double minVal, double maxVal, double currentVal, boolean showDec, boolean drawStr)
- {
- super(id, xPos, yPos, width, height, prefix, suf, minVal, maxVal, currentVal, showDec, drawStr);
- updateSlider();
- }
- public void updateSlider()
- {
- if (sliderValue < 0.0D)
- {
- sliderValue = 0.0D;
- }
- if (sliderValue > 1.0D)
- {
- sliderValue = 1.0D;
- }
- if (Math.abs(sliderValue - 0.5D) < 0.006D) {
- sliderValue = 0.5D;
- }
- if (drawString)
- {
- String val = Integer.toString((int)Math.round(100.0D * Math.pow(10.0D, getValue())));
- field_146126_j = (dispString + val + suffix);
- }
- if (parent != null)
- {
- parent.onChangeSliderValue(this);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment