Search in sources :

Example 1 with IModule

use of icyllis.modernui.test.discard.IModule in project ModernUI by BloCamLimb.

the class SettingGeneral method addGameCategory.

private void addGameCategory(List<SettingCategoryGroup> groups) {
    List<SettingEntry> list = new ArrayList<>();
    List<String> difficulties = Lists.newArrayList(Difficulty.values()).stream().map(d -> d.getDisplayName().getString()).collect(Collectors.toCollection(ArrayList::new));
    if (minecraft.world != null) {
        difficultyEntry = new DropdownSettingEntry(window, I18n.format("options.difficulty"), difficulties, minecraft.world.getDifficulty().getId(), i -> {
            Difficulty difficulty = Difficulty.values()[i];
            Objects.requireNonNull(minecraft.getConnection()).sendPacket(new CSetDifficultyPacket(difficulty));
        });
        list.add(difficultyEntry);
        if (minecraft.isSingleplayer() && !minecraft.world.getWorldInfo().isHardcore()) {
            boolean locked = minecraft.world.getWorldInfo().isDifficultyLocked();
            lockEntry = new BooleanSettingEntry(window, I18n.format("difficulty.lock.title"), locked, yes -> {
                if (yes) {
                    IModule popup = new PopupConfirm(this::lockDifficulty, 3).setConfirmTitle(I18n.format("gui.modernui.button.Lock")).setDescription(I18n.format("gui.modernui.popup.lockDifficulty"));
                    UIManager.getInstance().openPopup(popup, true);
                }
            }, true);
            difficultyEntry.setAvailable(!locked);
            lockEntry.setAvailable(!locked);
            list.add(lockEntry);
        } else {
            difficultyEntry.setAvailable(false);
        }
    }
    list.add(SettingsManager.REALMS_NOTIFICATIONS.apply(window));
    SettingCategoryGroup categoryGroup = new SettingCategoryGroup(window, I18n.format("gui.modernui.settings.category.game"), list);
    groups.add(categoryGroup);
}
Also used : ConfirmCallback(icyllis.modernui.test.popup.ConfirmCallback) ModernUI(icyllis.modernui.system.ModernUI) PopupConfirm(icyllis.modernui.test.popup.PopupConfirm) SettingScrollWindow(icyllis.modernui.impl.setting.SettingScrollWindow) CLockDifficultyPacket(net.minecraft.network.play.client.CLockDifficultyPacket) Collectors(java.util.stream.Collectors) UIManager(icyllis.modernui.view.UIManager) ArrayList(java.util.ArrayList) I18n(net.minecraft.client.resources.I18n) Objects(java.util.Objects) List(java.util.List) Lists(com.google.common.collect.Lists) CSetDifficultyPacket(net.minecraft.network.play.client.CSetDifficultyPacket) IModule(icyllis.modernui.test.discard.IModule) SettingsManager(icyllis.modernui.system.SettingsManager) GameSettings(net.minecraft.client.GameSettings) Module(icyllis.modernui.test.discard.Module) PlayerModelPart(net.minecraft.entity.player.PlayerModelPart) icyllis.modernui.impl.setting(icyllis.modernui.impl.setting) Difficulty(net.minecraft.world.Difficulty) IModule(icyllis.modernui.test.discard.IModule) Difficulty(net.minecraft.world.Difficulty) ArrayList(java.util.ArrayList) CSetDifficultyPacket(net.minecraft.network.play.client.CSetDifficultyPacket) PopupConfirm(icyllis.modernui.test.popup.PopupConfirm)

Example 2 with IModule

use of icyllis.modernui.test.discard.IModule in project ModernUI by BloCamLimb.

the class IngameMenuHome method exitToTitle.

private void exitToTitle() {
    playSound(Registration.BUTTON_CLICK_2);
    IModule popup = new PopupConfirm(this::confirmExit).setConfirmTitle(I18n.format("gui.modernui.button.exit")).setDescription(I18n.format("gui.modernui.popup.exit"));
    UIManager.getInstance().openPopup(popup, true);
}
Also used : IModule(icyllis.modernui.test.discard.IModule) PopupConfirm(icyllis.modernui.test.popup.PopupConfirm)

Aggregations

IModule (icyllis.modernui.test.discard.IModule)2 PopupConfirm (icyllis.modernui.test.popup.PopupConfirm)2 Lists (com.google.common.collect.Lists)1 icyllis.modernui.impl.setting (icyllis.modernui.impl.setting)1 SettingScrollWindow (icyllis.modernui.impl.setting.SettingScrollWindow)1 ModernUI (icyllis.modernui.system.ModernUI)1 SettingsManager (icyllis.modernui.system.SettingsManager)1 Module (icyllis.modernui.test.discard.Module)1 ConfirmCallback (icyllis.modernui.test.popup.ConfirmCallback)1 UIManager (icyllis.modernui.view.UIManager)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Objects (java.util.Objects)1 Collectors (java.util.stream.Collectors)1 GameSettings (net.minecraft.client.GameSettings)1 I18n (net.minecraft.client.resources.I18n)1 PlayerModelPart (net.minecraft.entity.player.PlayerModelPart)1 CLockDifficultyPacket (net.minecraft.network.play.client.CLockDifficultyPacket)1 CSetDifficultyPacket (net.minecraft.network.play.client.CSetDifficultyPacket)1 Difficulty (net.minecraft.world.Difficulty)1