-
Notifications
You must be signed in to change notification settings - Fork 809
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add api to add custom screens, use a color theme builder instead of a…
… direct method
- Loading branch information
Showing
22 changed files
with
228 additions
and
34 deletions.
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
common/src/api/java/net/caffeinemc/mods/sodium/api/config/structure/ColorThemeBuilder.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,7 @@ | ||
package net.caffeinemc.mods.sodium.api.config.structure; | ||
|
||
public interface ColorThemeBuilder { | ||
ColorThemeBuilder setBaseThemeRGB(int theme); | ||
|
||
ColorThemeBuilder setFullThemeRGB(int theme, int themeHighlight, int themeDisabled); | ||
} |
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
12 changes: 12 additions & 0 deletions
12
common/src/api/java/net/caffeinemc/mods/sodium/api/config/structure/ExternalPageBuilder.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,12 @@ | ||
package net.caffeinemc.mods.sodium.api.config.structure; | ||
|
||
import net.minecraft.client.gui.screens.Screen; | ||
import net.minecraft.network.chat.Component; | ||
|
||
import java.util.function.Consumer; | ||
|
||
public interface ExternalPageBuilder extends PageBuilder { | ||
ExternalPageBuilder setName(Component name); | ||
|
||
ExternalPageBuilder setScreenProvider(Consumer<Screen> currentScreenConsumer); | ||
} |
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
4 changes: 4 additions & 0 deletions
4
common/src/api/java/net/caffeinemc/mods/sodium/api/config/structure/PageBuilder.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,4 @@ | ||
package net.caffeinemc.mods.sodium.api.config.structure; | ||
|
||
public interface PageBuilder { | ||
} |
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
36 changes: 36 additions & 0 deletions
36
...c/main/java/net/caffeinemc/mods/sodium/client/config/structure/ColorThemeBuilderImpl.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,36 @@ | ||
package net.caffeinemc.mods.sodium.client.config.structure; | ||
|
||
import net.caffeinemc.mods.sodium.api.config.structure.ColorThemeBuilder; | ||
import net.caffeinemc.mods.sodium.client.gui.ColorTheme; | ||
|
||
public class ColorThemeBuilderImpl implements ColorThemeBuilder { | ||
private int baseTheme; | ||
private int themeHighlight; | ||
private int themeDisabled; | ||
|
||
ColorTheme build() { | ||
if (this.baseTheme == 0) { | ||
throw new IllegalStateException("Base theme must be set"); | ||
} | ||
|
||
if (this.themeHighlight == 0 || this.themeDisabled == 0) { | ||
return new ColorTheme(this.baseTheme); | ||
} else { | ||
return new ColorTheme(this.baseTheme, this.themeHighlight, this.themeDisabled); | ||
} | ||
} | ||
|
||
@Override | ||
public ColorThemeBuilder setBaseThemeRGB(int theme) { | ||
this.baseTheme = theme; | ||
return this; | ||
} | ||
|
||
@Override | ||
public ColorThemeBuilder setFullThemeRGB(int theme, int themeHighlight, int themeDisabled) { | ||
this.baseTheme = theme; | ||
this.themeHighlight = themeHighlight; | ||
this.themeDisabled = themeDisabled; | ||
return this; | ||
} | ||
} |
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
14 changes: 14 additions & 0 deletions
14
common/src/main/java/net/caffeinemc/mods/sodium/client/config/structure/ExternalPage.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,14 @@ | ||
package net.caffeinemc.mods.sodium.client.config.structure; | ||
|
||
import com.google.common.collect.ImmutableList; | ||
import net.minecraft.client.gui.screens.Screen; | ||
import net.minecraft.network.chat.Component; | ||
|
||
import java.util.function.Consumer; | ||
|
||
public record ExternalPage(Component name, Consumer<Screen> currentScreenConsumer) implements Page { | ||
@Override | ||
public ImmutableList<OptionGroup> groups() { | ||
return ImmutableList.of(); | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
...main/java/net/caffeinemc/mods/sodium/client/config/structure/ExternalPageBuilderImpl.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,33 @@ | ||
package net.caffeinemc.mods.sodium.client.config.structure; | ||
|
||
import net.caffeinemc.mods.sodium.api.config.structure.ExternalPageBuilder; | ||
import net.minecraft.client.gui.screens.Screen; | ||
import net.minecraft.network.chat.Component; | ||
import org.apache.commons.lang3.Validate; | ||
|
||
import java.util.function.Consumer; | ||
|
||
public class ExternalPageBuilderImpl extends PageBuilderImpl implements ExternalPageBuilder { | ||
private Component name; | ||
private Consumer<Screen> currentScreenConsumer; | ||
|
||
@Override | ||
ExternalPage build() { | ||
Validate.notNull(this.name, "Name must not be null"); | ||
Validate.notNull(this.currentScreenConsumer, "Screen consumer must not be null"); | ||
|
||
return new ExternalPage(this.name, this.currentScreenConsumer); | ||
} | ||
|
||
@Override | ||
public ExternalPageBuilder setName(Component name) { | ||
this.name = name; | ||
return this; | ||
} | ||
|
||
@Override | ||
public ExternalPageBuilder setScreenProvider(Consumer<Screen> currentScreenConsumer) { | ||
this.currentScreenConsumer = currentScreenConsumer; | ||
return this; | ||
} | ||
} |
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
10 changes: 10 additions & 0 deletions
10
common/src/main/java/net/caffeinemc/mods/sodium/client/config/structure/Page.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,10 @@ | ||
package net.caffeinemc.mods.sodium.client.config.structure; | ||
|
||
import com.google.common.collect.ImmutableList; | ||
import net.minecraft.network.chat.Component; | ||
|
||
public interface Page { | ||
Component name(); | ||
|
||
ImmutableList<OptionGroup> groups(); | ||
} |
5 changes: 5 additions & 0 deletions
5
common/src/main/java/net/caffeinemc/mods/sodium/client/config/structure/PageBuilderImpl.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,5 @@ | ||
package net.caffeinemc.mods.sodium.client.config.structure; | ||
|
||
public abstract class PageBuilderImpl { | ||
abstract Page build(); | ||
} |
10 changes: 10 additions & 0 deletions
10
common/src/main/java/net/caffeinemc/mods/sodium/client/gui/ColorTheme.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,15 +1,25 @@ | ||
package net.caffeinemc.mods.sodium.client.gui; | ||
|
||
import java.util.stream.Stream; | ||
|
||
public class ColorTheme { | ||
public final int theme; | ||
public final int themeLighter; | ||
public final int themeDarker; | ||
|
||
public static final ColorTheme DEFAULT = new ColorTheme(Colors.THEME, Colors.THEME_LIGHTER, Colors.THEME_DARKER); | ||
|
||
public static final ColorTheme[] PRESETS = Stream.of( | ||
0xFFE494A5, 0xFFAB94E4, 0xFFCDE494, 0xFFD394E4, 0xFFE4D394 | ||
).map(ColorTheme::new).toArray(ColorTheme[]::new); | ||
|
||
public ColorTheme(int theme, int themeLighter, int themeDarker) { | ||
this.theme = theme; | ||
this.themeLighter = themeLighter; | ||
this.themeDarker = themeDarker; | ||
} | ||
|
||
public ColorTheme(int theme) { | ||
this(theme, Colors.lighten(theme), Colors.darken(theme)); | ||
} | ||
} |
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
Oops, something went wrong.