|
| 1 | +/* |
| 2 | + * This library is free software; you can redistribute it and/or |
| 3 | + * modify it under the terms of the GNU Lesser General Public |
| 4 | + * License as published by the Free Software Foundation; either |
| 5 | + * version 2.1 of the License, or (at your option) any later version. |
| 6 | + * |
| 7 | + * This library is distributed in the hope that it will be useful, |
| 8 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 9 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 10 | + * Lesser General Public License for more details. |
| 11 | + * |
| 12 | + * You should have received a copy of the GNU Lesser General Public |
| 13 | + * License along with this library; if not, write to the Free Software |
| 14 | + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 15 | + */ |
| 16 | + |
| 17 | +package net.labymod.addons.optifine.v1_21_10.gui; |
| 18 | + |
| 19 | +import java.util.function.BiFunction; |
| 20 | +import javax.inject.Singleton; |
| 21 | +import net.labymod.addons.optifine.gui.OptiFineScreen; |
| 22 | +import net.labymod.addons.optifine.gui.ScreenHandler; |
| 23 | +import net.labymod.api.client.gui.screen.game.GameScreen; |
| 24 | +import net.labymod.api.models.Implements; |
| 25 | +import net.minecraft.client.Minecraft; |
| 26 | +import net.minecraft.client.Options; |
| 27 | +import net.minecraft.client.gui.screens.Screen; |
| 28 | +import net.optifine.gui.GuiAnimationSettingsOF; |
| 29 | +import net.optifine.gui.GuiDetailSettingsOF; |
| 30 | +import net.optifine.gui.GuiOtherSettingsOF; |
| 31 | +import net.optifine.gui.GuiPerformanceSettingsOF; |
| 32 | +import net.optifine.gui.GuiQualitySettingsOF; |
| 33 | +import net.optifine.shaders.gui.GuiShaders; |
| 34 | + |
| 35 | +@Singleton |
| 36 | +@Implements(ScreenHandler.class) |
| 37 | +public class VersionedScreenHandler extends ScreenHandler<Screen, Options> { |
| 38 | + |
| 39 | + @Override |
| 40 | + public void onInitialize() { |
| 41 | + this.registerOptions(OptiFineScreen.ANIMATION, GuiAnimationSettingsOF.class, GuiAnimationSettingsOF::new); |
| 42 | + this.registerOptions(OptiFineScreen.DETAIL, GuiDetailSettingsOF.class, GuiDetailSettingsOF::new); |
| 43 | + this.registerOptions(OptiFineScreen.OTHER, GuiOtherSettingsOF.class, GuiOtherSettingsOF::new); |
| 44 | + this.registerOptions(OptiFineScreen.PERFORMANCE, GuiPerformanceSettingsOF.class, GuiPerformanceSettingsOF::new); |
| 45 | + this.registerOptions(OptiFineScreen.QUALITY, GuiQualitySettingsOF.class, GuiQualitySettingsOF::new); |
| 46 | + this.registerOptions(OptiFineScreen.SHADERS, GuiShaders.class, GuiShaders::new); |
| 47 | + } |
| 48 | + |
| 49 | + @Override |
| 50 | + public void registerOptions( |
| 51 | + GameScreen screen, |
| 52 | + Class<?> screenClass, |
| 53 | + BiFunction<Screen, Options, Screen> screenFactory |
| 54 | + ) { |
| 55 | + this.register( |
| 56 | + screen, |
| 57 | + screenClass, |
| 58 | + () -> screenFactory.apply(Minecraft.getInstance().screen, Minecraft.getInstance().options) |
| 59 | + ); |
| 60 | + } |
| 61 | + |
| 62 | +} |
0 commit comments