forked from CaffeineMC/sodium
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add api methods to add button that redirects to an external page
- Loading branch information
Showing
39 changed files
with
766 additions
and
319 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
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
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
25 changes: 25 additions & 0 deletions
25
...api/java/net/caffeinemc/mods/sodium/api/config/structure/ExternalButtonOptionBuilder.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,25 @@ | ||
package net.caffeinemc.mods.sodium.api.config.structure; | ||
|
||
import net.caffeinemc.mods.sodium.api.config.ConfigState; | ||
import net.minecraft.client.gui.screens.Screen; | ||
import net.minecraft.network.chat.Component; | ||
import net.minecraft.resources.ResourceLocation; | ||
|
||
import java.util.function.Consumer; | ||
import java.util.function.Function; | ||
|
||
public interface ExternalButtonOptionBuilder extends OptionBuilder { | ||
ExternalButtonOptionBuilder setScreenProvider(Consumer<Screen> currentScreenConsumer); | ||
|
||
@Override | ||
ExternalButtonOptionBuilder setName(Component name); | ||
|
||
@Override | ||
ExternalButtonOptionBuilder setTooltip(Component tooltip); | ||
|
||
@Override | ||
ExternalButtonOptionBuilder setEnabled(boolean available); | ||
|
||
@Override | ||
ExternalButtonOptionBuilder setEnabledProvider(Function<ConfigState, Boolean> provider, ResourceLocation... dependencies); | ||
} |
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
33 changes: 6 additions & 27 deletions
33
common/src/api/java/net/caffeinemc/mods/sodium/api/config/structure/OptionBuilder.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,38 +1,17 @@ | ||
package net.caffeinemc.mods.sodium.api.config.structure; | ||
|
||
import net.caffeinemc.mods.sodium.api.config.*; | ||
import net.caffeinemc.mods.sodium.api.config.option.OptionBinding; | ||
import net.caffeinemc.mods.sodium.api.config.option.OptionFlag; | ||
import net.caffeinemc.mods.sodium.api.config.option.OptionImpact; | ||
import net.caffeinemc.mods.sodium.api.config.ConfigState; | ||
import net.minecraft.network.chat.Component; | ||
import net.minecraft.resources.ResourceLocation; | ||
|
||
import java.util.function.Consumer; | ||
import java.util.function.Function; | ||
import java.util.function.Supplier; | ||
|
||
public interface OptionBuilder<V> { | ||
OptionBuilder<V> setName(Component name); | ||
public interface OptionBuilder { | ||
OptionBuilder setName(Component name); | ||
|
||
OptionBuilder<V> setStorageHandler(StorageEventHandler storage); | ||
OptionBuilder setTooltip(Component tooltip); | ||
|
||
OptionBuilder<V> setTooltip(Component tooltip); | ||
OptionBuilder setEnabled(boolean available); | ||
|
||
OptionBuilder<V> setTooltip(Function<V, Component> tooltip); | ||
|
||
OptionBuilder<V> setImpact(OptionImpact impact); | ||
|
||
OptionBuilder<V> setFlags(OptionFlag... flags); | ||
|
||
OptionBuilder<V> setDefaultValue(V value); | ||
|
||
OptionBuilder<V> setDefaultProvider(Function<ConfigState, V> provider, ResourceLocation... dependencies); | ||
|
||
OptionBuilder<V> setEnabled(boolean available); | ||
|
||
OptionBuilder<V> setEnabledProvider(Function<ConfigState, Boolean> provider, ResourceLocation... dependencies); | ||
|
||
OptionBuilder<V> setBinding(Consumer<V> save, Supplier<V> load); | ||
|
||
OptionBuilder<V> setBinding(OptionBinding<V> binding); | ||
OptionBuilder setEnabledProvider(Function<ConfigState, Boolean> provider, ResourceLocation... dependencies); | ||
} |
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
31 changes: 31 additions & 0 deletions
31
...n/src/api/java/net/caffeinemc/mods/sodium/api/config/structure/StatefulOptionBuilder.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,31 @@ | ||
package net.caffeinemc.mods.sodium.api.config.structure; | ||
|
||
import net.caffeinemc.mods.sodium.api.config.ConfigState; | ||
import net.caffeinemc.mods.sodium.api.config.StorageEventHandler; | ||
import net.caffeinemc.mods.sodium.api.config.option.OptionBinding; | ||
import net.caffeinemc.mods.sodium.api.config.option.OptionFlag; | ||
import net.caffeinemc.mods.sodium.api.config.option.OptionImpact; | ||
import net.minecraft.network.chat.Component; | ||
import net.minecraft.resources.ResourceLocation; | ||
|
||
import java.util.function.Consumer; | ||
import java.util.function.Function; | ||
import java.util.function.Supplier; | ||
|
||
public interface StatefulOptionBuilder<V> extends OptionBuilder { | ||
StatefulOptionBuilder<V> setStorageHandler(StorageEventHandler storage); | ||
|
||
StatefulOptionBuilder<V> setTooltip(Function<V, Component> tooltip); | ||
|
||
StatefulOptionBuilder<V> setImpact(OptionImpact impact); | ||
|
||
StatefulOptionBuilder<V> setFlags(OptionFlag... flags); | ||
|
||
StatefulOptionBuilder<V> setDefaultValue(V value); | ||
|
||
StatefulOptionBuilder<V> setDefaultProvider(Function<ConfigState, V> provider, ResourceLocation... dependencies); | ||
|
||
StatefulOptionBuilder<V> setBinding(Consumer<V> save, Supplier<V> load); | ||
|
||
StatefulOptionBuilder<V> setBinding(OptionBinding<V> binding); | ||
} |
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
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
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
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
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
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
25 changes: 25 additions & 0 deletions
25
...rc/main/java/net/caffeinemc/mods/sodium/client/config/structure/ExternalButtonOption.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,25 @@ | ||
package net.caffeinemc.mods.sodium.client.config.structure; | ||
|
||
import net.caffeinemc.mods.sodium.client.config.value.DependentValue; | ||
import net.caffeinemc.mods.sodium.client.gui.options.control.Control; | ||
import net.caffeinemc.mods.sodium.client.gui.options.control.ExternalButtonControl; | ||
import net.minecraft.client.gui.screens.Screen; | ||
import net.minecraft.network.chat.Component; | ||
import net.minecraft.resources.ResourceLocation; | ||
|
||
import java.util.Collection; | ||
import java.util.function.Consumer; | ||
|
||
public class ExternalButtonOption extends StaticOption { | ||
final Consumer<Screen> currentScreenConsumer; | ||
|
||
ExternalButtonOption(ResourceLocation id, Collection<ResourceLocation> dependencies, Component name, DependentValue<Boolean> enabled, Component tooltip, Consumer<Screen> currentScreenConsumer) { | ||
super(id, dependencies, name, enabled, tooltip); | ||
this.currentScreenConsumer = currentScreenConsumer; | ||
} | ||
|
||
@Override | ||
Control createControl() { | ||
return new ExternalButtonControl(this, this.currentScreenConsumer); | ||
} | ||
} |
63 changes: 63 additions & 0 deletions
63
...a/net/caffeinemc/mods/sodium/client/config/structure/ExternalButtonOptionBuilderImpl.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,63 @@ | ||
package net.caffeinemc.mods.sodium.client.config.structure; | ||
|
||
import net.caffeinemc.mods.sodium.api.config.ConfigState; | ||
import net.caffeinemc.mods.sodium.api.config.structure.ExternalButtonOptionBuilder; | ||
import net.minecraft.client.gui.screens.Screen; | ||
import net.minecraft.network.chat.Component; | ||
import net.minecraft.resources.ResourceLocation; | ||
import org.apache.commons.lang3.Validate; | ||
|
||
import java.util.function.Consumer; | ||
import java.util.function.Function; | ||
|
||
class ExternalButtonOptionBuilderImpl extends StaticOptionBuilderImpl implements ExternalButtonOptionBuilder { | ||
private Consumer<Screen> currentScreenConsumer; | ||
|
||
ExternalButtonOptionBuilderImpl(ResourceLocation id) { | ||
super(id); | ||
} | ||
|
||
@Override | ||
void prepareBuild() { | ||
super.prepareBuild(); | ||
|
||
Validate.notNull(this.currentScreenConsumer, "Screen provider must be set"); | ||
} | ||
|
||
@Override | ||
Option build() { | ||
this.prepareBuild(); | ||
|
||
return new ExternalButtonOption(this.id, this.getDependencies(), this.name, this.enabled, this.tooltip, this.currentScreenConsumer); | ||
} | ||
|
||
@Override | ||
public ExternalButtonOptionBuilder setScreenProvider(Consumer<Screen> currentScreenConsumer) { | ||
this.currentScreenConsumer = currentScreenConsumer; | ||
return this; | ||
} | ||
|
||
@Override | ||
public ExternalButtonOptionBuilder setName(Component name) { | ||
super.setName(name); | ||
return this; | ||
} | ||
|
||
@Override | ||
public ExternalButtonOptionBuilder setEnabled(boolean available) { | ||
super.setEnabled(available); | ||
return this; | ||
} | ||
|
||
@Override | ||
public ExternalButtonOptionBuilder setEnabledProvider(Function<ConfigState, Boolean> provider, ResourceLocation... dependencies) { | ||
super.setEnabledProvider(provider, dependencies); | ||
return this; | ||
} | ||
|
||
@Override | ||
public ExternalButtonOptionBuilder setTooltip(Component tooltip) { | ||
super.setTooltip(tooltip); | ||
return this; | ||
} | ||
} |
Oops, something went wrong.