-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
905cec3
commit c934ad2
Showing
7 changed files
with
123 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
src/main/java/com/mrcrayfish/controllable/client/IToolTip.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.mrcrayfish.controllable.client; | ||
|
||
import net.minecraft.util.IReorderingProcessor; | ||
import net.minecraft.util.text.ITextComponent; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* Author: MrCrayfish | ||
*/ | ||
public interface IToolTip | ||
{ | ||
List<IReorderingProcessor> getToolTip(); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 17 additions & 1 deletion
18
src/main/java/com/mrcrayfish/controllable/client/settings/ControllableBooleanOption.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,40 @@ | ||
package com.mrcrayfish.controllable.client.settings; | ||
|
||
import com.mrcrayfish.controllable.client.IToolTip; | ||
import net.minecraft.client.GameSettings; | ||
import net.minecraft.client.Minecraft; | ||
import net.minecraft.client.settings.BooleanOption; | ||
import net.minecraft.util.IReorderingProcessor; | ||
import net.minecraft.util.text.ITextComponent; | ||
import net.minecraft.util.text.TranslationTextComponent; | ||
|
||
import java.util.Collections; | ||
import java.util.List; | ||
import java.util.function.BiConsumer; | ||
import java.util.function.Predicate; | ||
|
||
/** | ||
* Author: MrCrayfish | ||
*/ | ||
public class ControllableBooleanOption extends BooleanOption | ||
public class ControllableBooleanOption extends BooleanOption implements IToolTip | ||
{ | ||
private TranslationTextComponent toolTip; | ||
|
||
public ControllableBooleanOption(String title, Predicate<GameSettings> getter, BiConsumer<GameSettings, Boolean> setter) | ||
{ | ||
super(title, getter, setter); | ||
this.toolTip = new TranslationTextComponent(title + ".desc"); | ||
} | ||
|
||
@Override | ||
public void nextValue(GameSettings settings) | ||
{ | ||
this.set(settings, String.valueOf(!this.get(settings))); | ||
} | ||
|
||
@Override | ||
public List<IReorderingProcessor> getToolTip() | ||
{ | ||
return Minecraft.getInstance().fontRenderer.trimStringToWidth(this.toolTip, 200); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 16 additions & 1 deletion
17
.../java/com/mrcrayfish/controllable/client/settings/ControllableSliderPercentageOption.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,43 @@ | ||
package com.mrcrayfish.controllable.client.settings; | ||
|
||
import com.mrcrayfish.controllable.client.IToolTip; | ||
import com.mrcrayfish.controllable.client.gui.widget.ControllableOptionSlider; | ||
import net.minecraft.client.GameSettings; | ||
import net.minecraft.client.Minecraft; | ||
import net.minecraft.client.gui.widget.Widget; | ||
import net.minecraft.client.settings.SliderPercentageOption; | ||
import net.minecraft.util.IReorderingProcessor; | ||
import net.minecraft.util.text.ITextComponent; | ||
import net.minecraft.util.text.TranslationTextComponent; | ||
|
||
import java.util.Collections; | ||
import java.util.List; | ||
import java.util.function.BiConsumer; | ||
import java.util.function.BiFunction; | ||
import java.util.function.Function; | ||
|
||
/** | ||
* Author: MrCrayfish | ||
*/ | ||
public class ControllableSliderPercentageOption extends SliderPercentageOption | ||
public class ControllableSliderPercentageOption extends SliderPercentageOption implements IToolTip | ||
{ | ||
private TranslationTextComponent toolTip; | ||
|
||
public ControllableSliderPercentageOption(String title, double minValue, double maxValue, float stepSize, Function<GameSettings, Double> getter, BiConsumer<GameSettings, Double> setter, BiFunction<GameSettings, SliderPercentageOption, ITextComponent> displayNameGetter) | ||
{ | ||
super(title, minValue, maxValue, stepSize, getter, setter, displayNameGetter); | ||
this.toolTip = new TranslationTextComponent(title + ".desc"); | ||
} | ||
|
||
@Override | ||
public Widget createWidget(GameSettings settings, int x, int y, int width) | ||
{ | ||
return new ControllableOptionSlider(settings, x, y, width, 20, this); | ||
} | ||
|
||
@Override | ||
public List<IReorderingProcessor> getToolTip() | ||
{ | ||
return Minecraft.getInstance().fontRenderer.trimStringToWidth(this.toolTip, 200); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters