Skip to content

Commit

Permalink
✏ Parent of config screen
Browse files Browse the repository at this point in the history
  • Loading branch information
ZiYueCommentary committed Apr 13, 2024
1 parent a1823bb commit 611f790
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions common/src/main/java/ziyue/tjmetro/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ public void set(Boolean value) {
() -> IDrawingExtends.format(Text.translatable("footer.tjmetro.weblate"), IDrawingExtends.LINK_STYLE.apply(Reference.WEBLATE))
);

public static Screen getConfigScreen() {
ConfigBuilder builder = ConfigBuilder.create().setTitle(Text.translatable("gui.tjmetro.options")).transparentBackground();
public static Screen getConfigScreen(Screen parent) {
ConfigBuilder builder = ConfigBuilder.create().setParentScreen(parent).setTitle(Text.translatable("gui.tjmetro.options")).transparentBackground();
ConfigEntryBuilder entryBuilder = builder.entryBuilder();
ConfigCategory categoryTianjinMetro = builder.getOrCreateCategory(Text.translatable("config.category.tjmetro"));
BooleanListEntry booleanMTRFilters = entryBuilder.startBooleanToggle(Text.translatable("config.tjmetro.enable_mtr_filters"), ENABLE_MTR_FILTERS.get()).setDefaultValue(ENABLE_MTR_FILTERS.getDefault()).build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ protected void afterInit(CallbackInfo ci) {
filter.btnScrollDown = new IconButton(this.leftPos - 22, this.topPos + 127, Text.translatable("button.tjmetro.scroll_down").withStyle(ChatFormatting.WHITE), button -> filter.filterIndex++, tianjin_Metro$ICONS, 16, 0);
filter.btnEnableAll = new IconButton(this.leftPos - 50, this.topPos + 10, Text.translatable("button.tjmetro.enable_all").withStyle(ChatFormatting.WHITE), button -> Filter.FILTERS.get(tianjin_Metro$getSelectedTab()).forEach(filter1 -> filter1.enabled = true), tianjin_Metro$ICONS, 32, 0);
filter.btnDisableAll = new IconButton(this.leftPos - 50, this.topPos + 32, Text.translatable("button.tjmetro.disable_all").withStyle(ChatFormatting.WHITE), button -> Filter.FILTERS.get(tianjin_Metro$getSelectedTab()).forEach(filter1 -> filter1.enabled = false), tianjin_Metro$ICONS, 48, 0);
filter.btnOptions = new IconButton(this.leftPos - 50, this.topPos + 54, Text.translatable("button.tjmetro.tianjin_metro_options").withStyle(ChatFormatting.WHITE), button -> minecraft.setScreen(Config.getConfigScreen()), tianjin_Metro$ICONS, 64, 0);
filter.btnOptions = new IconButton(this.leftPos - 50, this.topPos + 54, Text.translatable("button.tjmetro.tianjin_metro_options").withStyle(ChatFormatting.WHITE), button -> minecraft.setScreen(Config.getConfigScreen(this)), tianjin_Metro$ICONS, 64, 0);
addButton(filter.btnScrollUp);
addButton(filter.btnScrollDown);
addButton(filter.btnEnableAll);
Expand Down
2 changes: 1 addition & 1 deletion fabric/src/main/java/ziyue/tjmetro/ModMenuConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ public class ModMenuConfig implements ModMenuApi
{
@Override
public ConfigScreenFactory<?> getModConfigScreenFactory() {
return parent -> Config.getConfigScreen();
return Config::getConfigScreen;
}
}
2 changes: 1 addition & 1 deletion forge/src/main/java/ziyue/tjmetro/MainForge.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public MainForge() {
final IEventBus eventBus = FMLJavaModLoadingContext.get().getModEventBus();
EventBuses.registerModEventBus(Reference.MOD_ID, eventBus);

ModLoadingContext.get().registerExtensionPoint(ExtensionPoint.CONFIGGUIFACTORY, () -> (client, parent) -> Config.getConfigScreen());
ModLoadingContext.get().registerExtensionPoint(ExtensionPoint.CONFIGGUIFACTORY, () -> (client, parent) -> Config.getConfigScreen(parent));

ITEMS.register();
BLOCKS.register();
Expand Down

0 comments on commit 611f790

Please sign in to comment.