Skip to content

Commit

Permalink
feat: panorama registration option and config screen
Browse files Browse the repository at this point in the history
  • Loading branch information
bconlon1 committed Oct 25, 2024
1 parent ac39aed commit 8c76883
Show file tree
Hide file tree
Showing 18 changed files with 81 additions and 237 deletions.
1 change: 0 additions & 1 deletion runs/client/config/fml.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,3 @@ earlyWindowSkipGLVersions = []
maxThreads = -1
#Squir?
earlyWindowSquir = false

18 changes: 8 additions & 10 deletions runs/client/config/neoforge-client.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@

#Client only settings, mostly things related to rendering
[client]
#EXPERIMENTAL: Enable the NeoForge block rendering pipeline - fixes the lighting of custom models.
experimentalForgeLightPipelineEnabled = false
#When enabled, NeoForge will show any warnings that occurred during loading.
showLoadWarnings = true
#Set to true to use a combined DEPTH_STENCIL attachment instead of two separate ones.
useCombinedDepthStencilAttachment = false

#EXPERIMENTAL: Enable the NeoForge block rendering pipeline - fixes the lighting of custom models.
experimentalForgeLightPipelineEnabled = false
#When enabled, NeoForge will show any warnings that occurred during loading.
showLoadWarnings = true
#Set to true to use a combined DEPTH_STENCIL attachment instead of two separate ones.
useCombinedDepthStencilAttachment = false
#A config option mainly for developers. Logs out configuration values that do not have translations when running a client in a development environment.
logUntranslatedConfigurationWarnings = true
16 changes: 6 additions & 10 deletions runs/client/config/neoforge-common.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@

#General configuration settings
[general]
#A config option mainly for developers. Logs out modded item tags that do not have translations when running on integrated server. Format desired is tag.item.<namespace>.<path> for the translation key. Defaults to SILENCED.
#Allowed Values: SILENCED, DEV_SHORT, DEV_VERBOSE, PROD_SHORT, PROD_VERBOSE
logUntranslatedItemTagWarnings = "SILENCED"
#A config option mainly for developers. Logs out modded tags that are using the 'forge' namespace when running on integrated server. Defaults to DEV_SHORT.
#Allowed Values: SILENCED, DEV_SHORT, DEV_VERBOSE, PROD_SHORT, PROD_VERBOSE
logLegacyTagWarnings = "DEV_SHORT"

#A config option mainly for developers. Logs out modded item tags that do not have translations when running on integrated server. Format desired is tag.item.<namespace>.<path> for the translation key. Defaults to SILENCED.
#Allowed Values: SILENCED, DEV_SHORT, DEV_VERBOSE, PROD_SHORT, PROD_VERBOSE
logUntranslatedItemTagWarnings = "SILENCED"
#A config option mainly for developers. Logs out modded tags that are using the 'forge' namespace when running on integrated server. Defaults to DEV_SHORT.
#Allowed Values: SILENCED, DEV_SHORT, DEV_VERBOSE, PROD_SHORT, PROD_VERBOSE
logLegacyTagWarnings = "DEV_SHORT"
2 changes: 1 addition & 1 deletion runs/client/options.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version:3953
version:3955
ao:true
biomeBlendRadius:2
enableVsync:true
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// 1.20.4 2024-01-20T00:47:05.7179247 Pack Metadata
d80ebb5841143cd1b3ac9926dc3100ca5b1a7759 pack.mcmeta
// 1.21.1 2024-10-25T14:43:36.3142406 Pack Metadata
df2cdb8ffc69d6ccce673baf9fbb986751dd2ff1 pack.mcmeta
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// 1.20.4 2024-01-20T00:47:05.7039284 Languages: en_us for mod: cumulus_menus
0cb2af7dbbd8bd2ff78b335c92a753a3048b1730 assets/cumulus_menus/lang/en_us.json
// 1.21.1 2024-10-25T15:07:58.2618288 Languages: en_us for mod: cumulus_menus
651e807852cdb20e86bc8cbbb750b5bb89ab2473 assets/cumulus_menus/lang/en_us.json
9 changes: 9 additions & 0 deletions src/generated/resources/assets/cumulus_menus/lang/en_us.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
{
"config.cumulus_menus.client.menu.active_menu": "Sets the current active menu title screen",
"config.cumulus_menus.client.menu.active_menu.tooltip": "Sets the current active menu title screen",
"config.cumulus_menus.client.menu.enable_menu_api": "Determines whether the Menu API is enabled or not",
"config.cumulus_menus.client.menu.enable_menu_api.tooltip": "Determines whether the Menu API is enabled or not",
"config.cumulus_menus.client.menu.enable_menu_list_button": "Adds a button to the top right of the main menu screen to open a menu selection screen",
"config.cumulus_menus.client.menu.enable_menu_list_button.tooltip": "Adds a button to the top right of the main menu screen to open a menu selection screen",
"cumulus_menus.configuration.Menu": "Menu",
"cumulus_menus.configuration.Menu.button": "Options",
"cumulus_menus.configuration.Menu.tooltip": "Config options for menu settings",
"cumulus_menus.configuration.section.cumulus.menus.client.toml": "Client Settings",
"cumulus_menus.configuration.section.cumulus.menus.client.toml.title": "Cumulus Client Configuration",
"cumulus_menus.configuration.title": "Cumulus Configuration",
"cumulus_menus.menu_title.minecraft": "Minecraft",
"gui.cumulus_menus.button.menu_launch": "Launch Menu",
"gui.cumulus_menus.button.menu_list": "Menu List",
Expand Down
2 changes: 1 addition & 1 deletion src/generated/resources/pack.mcmeta
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
"description": {
"translate": "pack.cumulus_menus.mod.description"
},
"pack_format": 22
"pack_format": 34
}
}
4 changes: 4 additions & 0 deletions src/main/java/com/aetherteam/cumulus/Cumulus.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
import net.neoforged.fml.ModContainer;
import net.neoforged.fml.common.Mod;
import net.neoforged.fml.config.ModConfig;
import net.neoforged.neoforge.client.gui.ConfigurationScreen;
import net.neoforged.neoforge.client.gui.IConfigScreenFactory;
import net.neoforged.neoforge.data.event.GatherDataEvent;
import net.neoforged.neoforge.registries.DeferredRegister;
import net.neoforged.neoforge.registries.NewRegistryEvent;
Expand Down Expand Up @@ -48,6 +50,8 @@ public Cumulus(ModContainer mod, IEventBus bus, Dist dist) {
}

mod.registerConfig(ModConfig.Type.CLIENT, CumulusConfig.CLIENT_SPEC);

mod.registerExtensionPoint(IConfigScreenFactory.class, ConfigurationScreen::new);
}
}

Expand Down
124 changes: 13 additions & 111 deletions src/main/java/com/aetherteam/cumulus/api/Menu.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@

import com.aetherteam.cumulus.Cumulus;
import com.aetherteam.cumulus.mixin.mixins.client.accessor.ScreenAccessor;
import com.aetherteam.cumulus.mixin.mixins.client.accessor.TabButtonAccessor;
import net.minecraft.client.gui.components.WidgetSprites;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.gui.screens.TitleScreen;
import net.minecraft.client.renderer.CubeMap;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.sounds.Music;
Expand All @@ -20,24 +18,24 @@ public class Menu {
private final BooleanSupplier condition;
private final Runnable apply;
private final Music music;
private final Background background;
private final CubeMap panorama;

public Menu(ResourceLocation icon, Component name, TitleScreen screen, BooleanSupplier condition) {
this(icon, name, screen, condition, new Properties());
}

public Menu(ResourceLocation icon, Component name, TitleScreen screen, BooleanSupplier condition, Properties properties) {
this(icon, name, screen, condition, properties.apply, properties.music, properties.background);
this(icon, name, screen, condition, properties.apply, properties.music, properties.panorama);
}

public Menu(ResourceLocation icon, Component name, TitleScreen screen, BooleanSupplier condition, Runnable apply, Music music, Background background) {
public Menu(ResourceLocation icon, Component name, TitleScreen screen, BooleanSupplier condition, Runnable apply, Music music, CubeMap panorama) {
this.icon = icon;
this.name = name;
this.screen = screen;
this.condition = condition;
this.apply = apply;
this.music = music;
this.background = background;
this.panorama = panorama;
}

/**
Expand Down Expand Up @@ -83,10 +81,10 @@ public Music getMusic() {
}

/**
* @return A {@link Background} tied to this menu; this is used to replace dirt backgrounds.
* @return {@link CubeMap} for the menu panorama.
*/
public Background getBackground() {
return this.background;
public CubeMap getPanorama() {
return this.panorama;
}

/**
Expand All @@ -106,7 +104,7 @@ public String toString() {
public static class Properties {
private Runnable apply = () -> {};
private Music music = Musics.MENU;
private Background background = Background.MINECRAFT;
private CubeMap panorama = ScreenAccessor.cumulus$getCubeMap();

/**
* @see Menu#getApply()
Expand All @@ -125,115 +123,19 @@ public Properties music(Music music) {
}

/**
* @see Menu#getBackground()
* @see Menu#getPanorama()
*/
public Properties background(Background background) {
this.background = background;
public Properties panorama(CubeMap panorama) {
this.panorama = panorama;
return this;
}

public static Properties propertiesFromType(Menu menu) {
Properties props = new Properties();
props.apply = menu.apply;
props.music = menu.music;
props.background = menu.background;
props.panorama = menu.panorama;
return props;
}
}

public static class Background {
private static final ResourceLocation DEFAULT_REGULAR_BACKGROUND = Screen.MENU_BACKGROUND;
private static final ResourceLocation DEFAULT_HEADER_SEPARATOR = Screen.HEADER_SEPARATOR;
private static final ResourceLocation DEFAULT_FOOTER_SEPARATOR = Screen.FOOTER_SEPARATOR;
private static final WidgetSprites DEFAULT_TAB_BUTTON = TabButtonAccessor.cumulus$getSprites();

private ResourceLocation regularBackground = DEFAULT_REGULAR_BACKGROUND;
private ResourceLocation headerSeparator = DEFAULT_HEADER_SEPARATOR;
private ResourceLocation footerSeparator = DEFAULT_FOOTER_SEPARATOR;
private WidgetSprites tabButton = DEFAULT_TAB_BUTTON;

public static final Background MINECRAFT = new Background()
.regularBackground(DEFAULT_REGULAR_BACKGROUND)
.headerSeparator(DEFAULT_HEADER_SEPARATOR)
.footerSeparator(DEFAULT_FOOTER_SEPARATOR)
.tabButton(DEFAULT_TAB_BUTTON);

/**
* Applies a background through mixin accessors.
* @param background The {@link Background} to apply.
*/
public static void apply(Background background) {
ScreenAccessor.cumulus$setMenuBackground(background.getRegularBackground());
ScreenAccessor.cumulus$setHeaderSeparator(background.getHeaderSeparator());
ScreenAccessor.cumulus$setFooterSeparator(background.getFooterSeparator());
TabButtonAccessor.cumulus$setSprites(background.getTabButton());
}

/**
* Resets the background to the default {@link Background#MINECRAFT} one.
*/
public static void reset() {
apply(MINECRAFT);
}

/**
* @see Background#getRegularBackground()
*/
public Background regularBackground(ResourceLocation regularBackground) {
this.regularBackground = regularBackground;
return this;
}

/**
* @see Background#getHeaderSeparator()
*/
public Background headerSeparator(ResourceLocation headerSeparator) {
this.headerSeparator = headerSeparator;
return this;
}

/**
* @see Background#getFooterSeparator()
*/
public Background footerSeparator(ResourceLocation footerSeparator) {
this.footerSeparator = footerSeparator;
return this;
}

/**
* @see Background#getTabButton()
*/
public Background tabButton(WidgetSprites tabButton) {
this.tabButton = tabButton;
return this;
}

/**
* @return The {@link ResourceLocation} for the regular dirt background texture to replace.
*/
public ResourceLocation getRegularBackground() {
return this.regularBackground;
}

/**
* @return The {@link ResourceLocation} for the dirt header separator texture to replace.
*/
public ResourceLocation getHeaderSeparator() {
return this.headerSeparator;
}

/**
* @return The {@link ResourceLocation} for the dirt footer separator texture to replace.
*/
public ResourceLocation getFooterSeparator() {
return this.footerSeparator;
}

/**
* @return The {@link ResourceLocation} for the dirt tab button texture to replace.
*/
public WidgetSprites getTabButton() {
return this.tabButton;
}
}
}
53 changes: 4 additions & 49 deletions src/main/java/com/aetherteam/cumulus/api/MenuHelper.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package com.aetherteam.cumulus.api;

import com.aetherteam.cumulus.CumulusConfig;
import com.aetherteam.cumulus.mixin.mixins.client.accessor.ScreenAccessor;
import com.aetherteam.cumulus.mixin.mixins.client.accessor.SplashRendererAccessor;
import com.aetherteam.cumulus.mixin.mixins.client.accessor.TitleScreenAccessor;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.gui.screens.TitleScreen;
import net.minecraft.client.renderer.PanoramaRenderer;
import net.minecraft.sounds.Music;

import javax.annotation.Nullable;
Expand All @@ -20,8 +22,6 @@ public class MenuHelper {
@Nullable
private TitleScreen fallbackTitleScreen = null;
@Nullable
private Menu.Background fallbackBackground = null;
@Nullable
private String lastSplash = null;
private boolean shouldFade = true;

Expand Down Expand Up @@ -65,8 +65,8 @@ public TitleScreen applyMenu(Menu menu) {
defaultMenuAccessor.cumulus$setFading(true);
defaultMenuAccessor.cumulus$setFadeInStart(0L);
}
Menu.Background background = this.checkFallbackBackground(menu, screen, menu.getBackground());
this.applyBackgrounds(background);
ScreenAccessor.cumulus$setCubeMap(menu.getPanorama());
ScreenAccessor.cumulus$setPanorama(new PanoramaRenderer(menu.getPanorama()));
if (this.getLastSplash() != null) {
this.migrateSplash(this.getLastSplash(), screen);
}
Expand All @@ -89,20 +89,6 @@ private TitleScreen checkFallbackScreen(Menu menu, TitleScreen screen) {
return screen;
}

/**
* Checks if there is a fallback {@link Menu.Background} to apply. This is used if another mod has custom dirt backgrounds.
* @param menu The current {@link Menu}.
* @param screen The current {@link Screen}.
* @param background The current {@link Menu.Background}.
* @return The fallback {@link Menu.Background}.
*/
private Menu.Background checkFallbackBackground(Menu menu, TitleScreen screen, Menu.Background background) {
if ((screen.getClass() == TitleScreen.class || menu == Menus.MINECRAFT.get()) && this.getFallbackBackground() != null) {
background = this.getFallbackBackground();
}
return background;
}

/**
* Resets the active menu to the default Minecraft menu.
*/
Expand Down Expand Up @@ -142,22 +128,6 @@ public void setFallbackTitleScreen(@Nullable TitleScreen fallbackTitleScreen) {
this.fallbackTitleScreen = fallbackTitleScreen;
}

/**
* @return The fallback {@link Menu.Background}.
*/
@Nullable
public Menu.Background getFallbackBackground() {
return this.fallbackBackground;
}

/**
* Sets the fallback {@link Menu.Background}.
* @param fallbackBackground The {@link Menu.Background}.
*/
public void setFallbackBackground(@Nullable Menu.Background fallbackBackground) {
this.fallbackBackground = fallbackBackground;
}

/**
* @return The {@link String} for the last displayed splash.
*/
Expand Down Expand Up @@ -206,21 +176,6 @@ public void setCustomSplash(TitleScreen screen, Predicate<Calendar> condition, S
}
}

/**
* Applies a background.
* @param background The {@link com.aetherteam.cumulus.api.Menu.Background}.
*/
public void applyBackgrounds(Menu.Background background) {
Menu.Background.apply(background);
}

/**
* Resets the background.
*/
public void resetBackgrounds() {
Menu.Background.reset();
}

/**
* Checks if a screen class matches an existing menu.
* @param titleScreen The {@link TitleScreen}.
Expand Down
Loading

0 comments on commit 8c76883

Please sign in to comment.