Search in sources :

Example 1 with SpeedRunIGTInfoScreen

use of com.redlimerl.speedrunigt.gui.screen.SpeedRunIGTInfoScreen in project SpeedRunIGT by RedLime.

the class OptionButtonsImpl method createOptionButtons.

@Override
public Collection<OptionButtonFactory> createOptionButtons() {
    ArrayList<OptionButtonFactory> factories = new ArrayList<>();
    factories.add(screen -> new OptionButtonFactory.Builder().setButtonWidget(new ButtonWidget(0, 0, 150, 20, new TranslatableText("speedrunigt.option.timer_position"), (ButtonWidget button) -> MinecraftClient.getInstance().openScreen(new TimerCustomizeScreen(screen)))).setCategory("speedrunigt.option.category.general"));
    factories.add(screen -> new OptionButtonFactory.Builder().setButtonWidget(new ButtonWidget(0, 0, 150, 20, new TranslatableText("speedrunigt.option.timer_category"), (ButtonWidget button) -> MinecraftClient.getInstance().openScreen(new SpeedRunCategoryScreen(screen)))).setCategory("speedrunigt.option.category.general"));
    factories.add(screen -> new OptionButtonFactory.Builder().setButtonWidget(new ButtonWidget(0, 0, 150, 20, new TranslatableText("speedrunigt.option.check_info"), (ButtonWidget button) -> MinecraftClient.getInstance().openScreen(new SpeedRunIGTInfoScreen(screen)))).setCategory("speedrunigt.option.category.general"));
    factories.add(screen -> new OptionButtonFactory.Builder().setButtonWidget(new ButtonWidget(0, 0, 150, 20, new TranslatableText("speedrunigt.option.reload"), (ButtonWidget button) -> MinecraftClient.getInstance().openScreen(new ConfirmScreen(boolean1 -> {
        if (boolean1) {
            SpeedRunOption.reload();
        }
        MinecraftClient.getInstance().openScreen(screen);
    }, new TranslatableText("speedrunigt.message.reload_options"), LiteralText.EMPTY)))).setCategory("speedrunigt.option.category.general"));
    factories.add(screen -> new OptionButtonFactory.Builder().setButtonWidget(new ButtonWidget(0, 0, 150, 20, new TranslatableText("speedrunigt.option.global_options").append(" : ").append(SpeedRunOption.isUsingGlobalConfig() ? ScreenTexts.ON : ScreenTexts.OFF), (ButtonWidget button) -> {
        SpeedRunOption.setUseGlobalConfig(!SpeedRunOption.isUsingGlobalConfig());
        MinecraftClient.getInstance().openScreen(new ConfirmScreen(boolean1 -> {
            if (boolean1) {
                SpeedRunOption.reload();
            }
            MinecraftClient.getInstance().openScreen(screen);
        }, new TranslatableText("speedrunigt.message.reload_options"), LiteralText.EMPTY));
    })).setToolTip(() -> I18n.translate("speedrunigt.option.global_options.description", SpeedRunOption.getConfigPath())).setCategory("speedrunigt.option.category.general"));
    factories.add(screen -> new OptionButtonFactory.Builder().setButtonWidget(new ButtonWidget(0, 0, 150, 20, new TranslatableText("speedrunigt.option.timer_position.toggle_timer").append(" : ").append(TIMER_DRAWER.isToggle() ? ScreenTexts.ON : ScreenTexts.OFF), (ButtonWidget button) -> {
        TIMER_DRAWER.setToggle(!TIMER_DRAWER.isToggle());
        SpeedRunOption.setOption(SpeedRunOptions.TOGGLE_TIMER, TIMER_DRAWER.isToggle());
        button.setMessage(new TranslatableText("speedrunigt.option.timer_position.toggle_timer").append(" : ").append(TIMER_DRAWER.isToggle() ? ScreenTexts.ON : ScreenTexts.OFF));
    })).setCategory("speedrunigt.option.category.timer"));
    factories.add(screen -> new OptionButtonFactory.Builder().setButtonWidget(new ButtonWidget(0, 0, 150, 20, new TranslatableText("speedrunigt.option.hide_timer_in_options").append(" : ").append(SpeedRunOption.getOption(SpeedRunOptions.HIDE_TIMER_IN_OPTIONS) ? ScreenTexts.ON : ScreenTexts.OFF), (ButtonWidget button) -> {
        SpeedRunOption.setOption(SpeedRunOptions.HIDE_TIMER_IN_OPTIONS, !SpeedRunOption.getOption(SpeedRunOptions.HIDE_TIMER_IN_OPTIONS));
        button.setMessage(new TranslatableText("speedrunigt.option.hide_timer_in_options").append(" : ").append(SpeedRunOption.getOption(SpeedRunOptions.HIDE_TIMER_IN_OPTIONS) ? ScreenTexts.ON : ScreenTexts.OFF));
    })).setCategory("speedrunigt.option.category.timer"));
    factories.add(screen -> new OptionButtonFactory.Builder().setButtonWidget(new ButtonWidget(0, 0, 150, 20, new TranslatableText("speedrunigt.option.hide_timer_in_debugs").append(" : ").append(SpeedRunOption.getOption(SpeedRunOptions.HIDE_TIMER_IN_DEBUGS) ? ScreenTexts.ON : ScreenTexts.OFF), (ButtonWidget button) -> {
        SpeedRunOption.setOption(SpeedRunOptions.HIDE_TIMER_IN_DEBUGS, !SpeedRunOption.getOption(SpeedRunOptions.HIDE_TIMER_IN_DEBUGS));
        button.setMessage(new TranslatableText("speedrunigt.option.hide_timer_in_debugs").append(" : ").append(SpeedRunOption.getOption(SpeedRunOptions.HIDE_TIMER_IN_DEBUGS) ? ScreenTexts.ON : ScreenTexts.OFF));
    })).setCategory("speedrunigt.option.category.timer"));
    factories.add(screen -> new OptionButtonFactory.Builder().setButtonWidget(new ButtonWidget(0, 0, 150, 20, new TranslatableText("speedrunigt.option.waiting_first_input").append(" : ").append(SpeedRunOption.getOption(SpeedRunOptions.WAITING_FIRST_INPUT) ? ScreenTexts.ON : ScreenTexts.OFF), (ButtonWidget button) -> {
        SpeedRunOption.setOption(SpeedRunOptions.WAITING_FIRST_INPUT, !SpeedRunOption.getOption(SpeedRunOptions.WAITING_FIRST_INPUT));
        button.setMessage(new TranslatableText("speedrunigt.option.waiting_first_input").append(" : ").append(SpeedRunOption.getOption(SpeedRunOptions.WAITING_FIRST_INPUT) ? ScreenTexts.ON : ScreenTexts.OFF));
    })).setToolTip(() -> I18n.translate("speedrunigt.option.waiting_first_input.description")).setCategory("speedrunigt.option.category.timing"));
    factories.add(screen -> new OptionButtonFactory.Builder().setButtonWidget(new ButtonWidget(0, 0, 150, 20, new TranslatableText("speedrunigt.option.auto_toggle_coop").append(" : ").append(SpeedRunOption.getOption(SpeedRunOptions.AUTOMATIC_COOP_MODE) ? ScreenTexts.ON : ScreenTexts.OFF), (ButtonWidget button) -> {
        SpeedRunOption.setOption(SpeedRunOptions.AUTOMATIC_COOP_MODE, !SpeedRunOption.getOption(SpeedRunOptions.AUTOMATIC_COOP_MODE));
        button.setMessage(new TranslatableText("speedrunigt.option.auto_toggle_coop").append(" : ").append(SpeedRunOption.getOption(SpeedRunOptions.AUTOMATIC_COOP_MODE) ? ScreenTexts.ON : ScreenTexts.OFF));
    })).setToolTip(() -> I18n.translate("speedrunigt.option.auto_toggle_coop.description")).setCategory("speedrunigt.option.category.timer"));
    factories.add(screen -> new OptionButtonFactory.Builder().setButtonWidget(new ButtonWidget(0, 0, 150, 20, new TranslatableText("speedrunigt.option.start_old_worlds").append(" : ").append(SpeedRunOption.getOption(SpeedRunOptions.TIMER_START_GENERATED_WORLD) ? ScreenTexts.ON : ScreenTexts.OFF), (ButtonWidget button) -> {
        SpeedRunOption.setOption(SpeedRunOptions.TIMER_START_GENERATED_WORLD, !SpeedRunOption.getOption(SpeedRunOptions.TIMER_START_GENERATED_WORLD));
        button.setMessage(new TranslatableText("speedrunigt.option.start_old_worlds").append(" : ").append(SpeedRunOption.getOption(SpeedRunOptions.TIMER_START_GENERATED_WORLD) ? ScreenTexts.ON : ScreenTexts.OFF));
    })).setToolTip(() -> I18n.translate("speedrunigt.option.start_old_worlds.description")).setCategory("speedrunigt.option.category.timing"));
    factories.add(screen -> new OptionButtonFactory.Builder().setButtonWidget(new ButtonWidget(0, 0, 150, 20, new TranslatableText("speedrunigt.option.limitless_reset").append(" : ").append(SpeedRunOption.getOption(SpeedRunOptions.TIMER_LIMITLESS_RESET) ? ScreenTexts.ON : ScreenTexts.OFF), (ButtonWidget button) -> {
        SpeedRunOption.setOption(SpeedRunOptions.TIMER_LIMITLESS_RESET, !SpeedRunOption.getOption(SpeedRunOptions.TIMER_LIMITLESS_RESET));
        button.setMessage(new TranslatableText("speedrunigt.option.limitless_reset").append(" : ").append(SpeedRunOption.getOption(SpeedRunOptions.TIMER_LIMITLESS_RESET) ? ScreenTexts.ON : ScreenTexts.OFF));
    })).setToolTip(() -> I18n.translate("speedrunigt.option.limitless_reset.description")).setCategory("speedrunigt.option.category.timing"));
    if (Math.random() < 0.1) {
        factories.add(screen -> new OptionButtonFactory.Builder().setButtonWidget(new ButtonWidget(0, 0, 150, 20, new LiteralText("amongus"), (ButtonWidget button) -> {
        })).setCategory("sus"));
    }
    factories.add(screen -> new OptionButtonFactory.Builder().setButtonWidget(new ButtonWidget(0, 0, 150, 20, new TranslatableText("speedrunigt.option.current_extensions"), (ButtonWidget button) -> {
    })).setToolTip(() -> {
        StringBuilder extension = new StringBuilder(I18n.translate("speedrunigt.option.current_extensions.description", SpeedRunIGTApi.getProviders().length));
        extension.append("\n");
        int auto = 0;
        for (ModContainer provider : SpeedRunIGTApi.getProviders()) {
            if (auto++ > 4) {
                auto = 0;
                extension.append("\n");
            }
            extension.append(String.format("%s v%s,", provider.getMetadata().getName(), provider.getMetadata().getVersion()));
        }
        return extension.substring(0, extension.length() - 1);
    }).setCategory("speedrunigt.option.category.general"));
    factories.add(screen -> new OptionButtonFactory.Builder().setButtonWidget(new ButtonWidget(0, 0, 150, 20, new TranslatableText("speedrunigt.option.legacy_igt_mode").append(" : ").append(SpeedRunOption.getOption(SpeedRunOptions.TIMER_LEGACY_IGT_MODE) ? ScreenTexts.ON : ScreenTexts.OFF), (ButtonWidget button) -> {
        SpeedRunOption.setOption(SpeedRunOptions.TIMER_LEGACY_IGT_MODE, !SpeedRunOption.getOption(SpeedRunOptions.TIMER_LEGACY_IGT_MODE));
        button.setMessage(new TranslatableText("speedrunigt.option.legacy_igt_mode").append(" : ").append(SpeedRunOption.getOption(SpeedRunOptions.TIMER_LEGACY_IGT_MODE) ? ScreenTexts.ON : ScreenTexts.OFF));
    })).setToolTip(() -> I18n.translate("speedrunigt.option.legacy_igt_mode.description")).setCategory("speedrunigt.option.category.timer"));
    factories.add(screen -> new OptionButtonFactory.Builder().setButtonWidget(new ButtonWidget(0, 0, 150, 20, new TranslatableText("speedrunigt.option.auto_save_interval").append(" : ").append(new TranslatableText("speedrunigt.option.auto_save_interval." + SpeedRunOption.getOption(SpeedRunOptions.TIMER_DATA_AUTO_SAVE).name().toLowerCase(Locale.ROOT))), (ButtonWidget button) -> {
        int order = SpeedRunOption.getOption(SpeedRunOptions.TIMER_DATA_AUTO_SAVE).ordinal() + 1;
        SpeedRunOptions.TimerSaveInterval[] intervals = SpeedRunOptions.TimerSaveInterval.values();
        SpeedRunOption.setOption(SpeedRunOptions.TIMER_DATA_AUTO_SAVE, intervals[order % intervals.length]);
        button.setMessage(new TranslatableText("speedrunigt.option.auto_save_interval").append(" : ").append(new TranslatableText("speedrunigt.option.auto_save_interval." + SpeedRunOption.getOption(SpeedRunOptions.TIMER_DATA_AUTO_SAVE).name().toLowerCase(Locale.ROOT))));
    })).setToolTip(() -> I18n.translate("speedrunigt.option.auto_save_interval.description")).setCategory("speedrunigt.option.category.timer"));
    factories.add(screen -> new OptionButtonFactory.Builder().setButtonWidget(new ButtonWidget(0, 0, 150, 20, new TranslatableText("speedrunigt.option.auto_retime").append(" : ").append(SpeedRunOption.getOption(SpeedRunOptions.AUTO_RETIME_FOR_GUIDELINE) ? ScreenTexts.ON : ScreenTexts.OFF), (ButtonWidget button) -> {
        SpeedRunOption.setOption(SpeedRunOptions.AUTO_RETIME_FOR_GUIDELINE, !SpeedRunOption.getOption(SpeedRunOptions.AUTO_RETIME_FOR_GUIDELINE));
        button.setMessage(new TranslatableText("speedrunigt.option.auto_retime").append(" : ").append(SpeedRunOption.getOption(SpeedRunOptions.AUTO_RETIME_FOR_GUIDELINE) ? ScreenTexts.ON : ScreenTexts.OFF));
    })).setToolTip(() -> I18n.translate("speedrunigt.option.auto_retime.description")).setCategory("speedrunigt.option.category.timer"));
    return factories;
}
Also used : TranslatableText(net.minecraft.text.TranslatableText) SpeedRunOption(com.redlimerl.speedrunigt.option.SpeedRunOption) SpeedRunOptions(com.redlimerl.speedrunigt.option.SpeedRunOptions) LiteralText(net.minecraft.text.LiteralText) ScreenTexts(net.minecraft.client.gui.screen.ScreenTexts) ConfirmScreen(net.minecraft.client.gui.screen.ConfirmScreen) I18n(net.minecraft.client.resource.language.I18n) SpeedRunCategoryScreen(com.redlimerl.speedrunigt.gui.screen.SpeedRunCategoryScreen) Collection(java.util.Collection) TranslatableText(net.minecraft.text.TranslatableText) ButtonWidget(net.minecraft.client.gui.widget.ButtonWidget) OptionButtonFactory(com.redlimerl.speedrunigt.api.OptionButtonFactory) ArrayList(java.util.ArrayList) TimerCustomizeScreen(com.redlimerl.speedrunigt.gui.screen.TimerCustomizeScreen) SpeedRunIGTInfoScreen(com.redlimerl.speedrunigt.gui.screen.SpeedRunIGTInfoScreen) Locale(java.util.Locale) SpeedRunIGTApi(com.redlimerl.speedrunigt.api.SpeedRunIGTApi) MinecraftClient(net.minecraft.client.MinecraftClient) TIMER_DRAWER(com.redlimerl.speedrunigt.SpeedRunIGT.TIMER_DRAWER) ModContainer(net.fabricmc.loader.api.ModContainer) SpeedRunIGTInfoScreen(com.redlimerl.speedrunigt.gui.screen.SpeedRunIGTInfoScreen) ModContainer(net.fabricmc.loader.api.ModContainer) ArrayList(java.util.ArrayList) TimerCustomizeScreen(com.redlimerl.speedrunigt.gui.screen.TimerCustomizeScreen) ButtonWidget(net.minecraft.client.gui.widget.ButtonWidget) ConfirmScreen(net.minecraft.client.gui.screen.ConfirmScreen) OptionButtonFactory(com.redlimerl.speedrunigt.api.OptionButtonFactory) SpeedRunCategoryScreen(com.redlimerl.speedrunigt.gui.screen.SpeedRunCategoryScreen) LiteralText(net.minecraft.text.LiteralText)

Aggregations

TIMER_DRAWER (com.redlimerl.speedrunigt.SpeedRunIGT.TIMER_DRAWER)1 OptionButtonFactory (com.redlimerl.speedrunigt.api.OptionButtonFactory)1 SpeedRunIGTApi (com.redlimerl.speedrunigt.api.SpeedRunIGTApi)1 SpeedRunCategoryScreen (com.redlimerl.speedrunigt.gui.screen.SpeedRunCategoryScreen)1 SpeedRunIGTInfoScreen (com.redlimerl.speedrunigt.gui.screen.SpeedRunIGTInfoScreen)1 TimerCustomizeScreen (com.redlimerl.speedrunigt.gui.screen.TimerCustomizeScreen)1 SpeedRunOption (com.redlimerl.speedrunigt.option.SpeedRunOption)1 SpeedRunOptions (com.redlimerl.speedrunigt.option.SpeedRunOptions)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 Locale (java.util.Locale)1 ModContainer (net.fabricmc.loader.api.ModContainer)1 MinecraftClient (net.minecraft.client.MinecraftClient)1 ConfirmScreen (net.minecraft.client.gui.screen.ConfirmScreen)1 ScreenTexts (net.minecraft.client.gui.screen.ScreenTexts)1 ButtonWidget (net.minecraft.client.gui.widget.ButtonWidget)1 I18n (net.minecraft.client.resource.language.I18n)1 LiteralText (net.minecraft.text.LiteralText)1 TranslatableText (net.minecraft.text.TranslatableText)1