reddvilzz

Untitled

May 8th, 2017
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.20 KB | None | 0 0
  1. package gigaherz.inventoryspam.config;
  2.  
  3. import cpw.mods.fml.client.config.GuiSlider;
  4.  
  5. public class ExponentialNumberSliderEntry extends cpw.mods.fml.client.config.GuiConfigEntries.ButtonEntry
  6. {
  7. protected final double beforeValue;
  8.  
  9. public ExponentialNumberSliderEntry(cpw.mods.fml.client.config.GuiConfig owningScreen, cpw.mods.fml.client.config.GuiConfigEntries owningEntryList, cpw.mods.fml.client.config.IConfigElement configElement)
  10. {
  11. super(owningScreen, owningEntryList, configElement, new GuiExponentialSlider(0, 0, 0, 18, 10, "", "%",
  12. Double.valueOf(configElement.getMinValue().toString()).doubleValue(), Double.valueOf(configElement.getMaxValue().toString()).doubleValue(),
  13. Double.valueOf(configElement.get().toString()).doubleValue(), configElement.getType() == cpw.mods.fml.client.config.ConfigGuiType.DOUBLE, true));
  14.  
  15. beforeValue = Double.valueOf(configElement.get().toString()).doubleValue();
  16. }
  17.  
  18.  
  19. public void updateValueButtonText()
  20. {
  21. ((GuiSlider)btnValue).updateSlider();
  22. }
  23.  
  24.  
  25. public void valueButtonPressed(int slotIndex) {}
  26.  
  27.  
  28. public boolean isDefault()
  29. {
  30. return ((GuiSlider)btnValue).getValue() == Double.valueOf(configElement.getDefault().toString()).doubleValue();
  31. }
  32.  
  33.  
  34. public void setToDefault()
  35. {
  36. if (enabled())
  37. {
  38. ((GuiSlider)btnValue).setValue(Double.valueOf(configElement.getDefault().toString()).doubleValue());
  39. ((GuiSlider)btnValue).updateSlider();
  40. }
  41. }
  42.  
  43.  
  44. public boolean isChanged()
  45. {
  46. return ((GuiSlider)btnValue).getValue() != beforeValue;
  47. }
  48.  
  49.  
  50. public void undoChanges()
  51. {
  52. if (enabled())
  53. {
  54. ((GuiSlider)btnValue).setValue(beforeValue);
  55. ((GuiSlider)btnValue).updateSlider();
  56. }
  57. }
  58.  
  59.  
  60. public boolean saveConfigElement()
  61. {
  62. if ((enabled()) && (isChanged()))
  63. {
  64. configElement.set(Double.valueOf(((GuiSlider)btnValue).getValue()));
  65. return configElement.requiresMcRestart();
  66. }
  67. return false;
  68. }
  69.  
  70.  
  71. public Object getCurrentValue()
  72. {
  73. return Double.valueOf(((GuiSlider)btnValue).getValue());
  74. }
  75.  
  76.  
  77. public Object[] getCurrentValues()
  78. {
  79. return new Object[] { getCurrentValue() };
  80. }
  81.  
  82. private static class GuiExponentialSlider extends GuiSlider
  83. {
  84. 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)
  85. {
  86. super(id, xPos, yPos, width, height, prefix, suf, minVal, maxVal, currentVal, showDec, drawStr);
  87. updateSlider();
  88. }
  89.  
  90.  
  91. public void updateSlider()
  92. {
  93. if (sliderValue < 0.0D)
  94. {
  95. sliderValue = 0.0D;
  96. }
  97.  
  98. if (sliderValue > 1.0D)
  99. {
  100. sliderValue = 1.0D;
  101. }
  102.  
  103. if (Math.abs(sliderValue - 0.5D) < 0.006D) {
  104. sliderValue = 0.5D;
  105. }
  106. if (drawString)
  107. {
  108. String val = Integer.toString((int)Math.round(100.0D * Math.pow(10.0D, getValue())));
  109. field_146126_j = (dispString + val + suffix);
  110. }
  111.  
  112. if (parent != null)
  113. {
  114. parent.onChangeSliderValue(this);
  115. }
  116. }
  117. }
  118. }
Advertisement
Add Comment
Please, Sign In to add comment