Search in sources :

Example 6 with GuiYesNo

use of net.minecraft.client.gui.GuiYesNo in project Cavern2 by kegare.

the class ClientEventHooks method onTick.

@SubscribeEvent
public void onTick(ClientTickEvent event) {
    if (event.phase != TickEvent.Phase.END) {
        return;
    }
    Minecraft mc = FMLClientHandler.instance().getClient();
    if (mc.currentScreen != null && mc.currentScreen instanceof GuiMainMenu && Config.configChecker.isUpdated() && !Config.configChecker.isNotified()) {
        String line1 = I18n.format("cavern.config.message.update");
        String line2 = I18n.format("cavern.config.message.open");
        GuiScreen parentScreen = mc.currentScreen;
        mc.displayGuiScreen(new GuiYesNo((result, id) -> {
            if (result) {
                IModGuiFactory guiFactory = FMLClientHandler.instance().getGuiFactoryFor(CaveUtils.getModContainer());
                GuiScreen guiConfig = guiFactory.createConfigGui(parentScreen);
                mc.displayGuiScreen(guiConfig);
            } else {
                mc.displayGuiScreen(parentScreen);
            }
        }, line1, line2, -1));
        Config.configChecker.setNotified(true);
    }
    if (!DELAYED_TOAST.isEmpty()) {
        Iterator<DelayedToast> iterator = DELAYED_TOAST.iterator();
        while (iterator.hasNext()) {
            if (!iterator.next().onUpdate()) {
                iterator.remove();
            }
        }
    }
}
Also used : AquaCavernConfig(cavern.config.AquaCavernConfig) DisplayConfig(cavern.config.DisplayConfig) Keyboard(org.lwjgl.input.Keyboard) GuiMainMenu(net.minecraft.client.gui.GuiMainMenu) TextComponentTranslation(net.minecraft.util.text.TextComponentTranslation) Config(cavern.config.Config) I18n(net.minecraft.client.resources.I18n) GuiDownloadCaveTerrain(cavern.client.gui.GuiDownloadCaveTerrain) GuiDownloadTerrain(net.minecraft.client.gui.GuiDownloadTerrain) Version(cavern.util.Version) Side(net.minecraftforge.fml.relauncher.Side) Cavern(cavern.core.Cavern) GuiMiningRecords(cavern.client.gui.GuiMiningRecords) ItemBowIce(cavern.item.ItemBowIce) DelayedToast(cavern.client.gui.toasts.DelayedToast) GlStateManager(net.minecraft.client.renderer.GlStateManager) CaveKeyBindings(cavern.client.CaveKeyBindings) EnchantmentHelper(net.minecraft.enchantment.EnchantmentHelper) GuiWorldSelection(net.minecraft.client.gui.GuiWorldSelection) CavernAPI(cavern.api.CavernAPI) List(java.util.List) CaveUtils(cavern.util.CaveUtils) FMLClientHandler(net.minecraftforge.fml.client.FMLClientHandler) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ItemTooltipEvent(net.minecraftforge.event.entity.player.ItemTooltipEvent) FogColors(net.minecraftforge.client.event.EntityViewRenderEvent.FogColors) Configuration(net.minecraftforge.common.config.Configuration) TickEvent(net.minecraftforge.fml.common.gameevent.TickEvent) ClientConnectedToServerEvent(net.minecraftforge.fml.common.network.FMLNetworkEvent.ClientConnectedToServerEvent) MobEffects(net.minecraft.init.MobEffects) MiningAssistConfig(cavern.config.MiningAssistConfig) PlayerLoggedInEvent(net.minecraftforge.fml.common.gameevent.PlayerEvent.PlayerLoggedInEvent) IIceEquipment(cavern.api.IIceEquipment) GuiLoadCaveTerrain(cavern.client.gui.GuiLoadCaveTerrain) GuiModList(net.minecraftforge.fml.client.GuiModList) MiningAssist(cavern.miningassist.MiningAssist) ClickEvent(net.minecraft.util.text.event.ClickEvent) CavernConfig(cavern.config.CavernConfig) FogDensity(net.minecraftforge.client.event.EntityViewRenderEvent.FogDensity) ClientTickEvent(net.minecraftforge.fml.common.gameevent.TickEvent.ClientTickEvent) GuiYesNo(net.minecraft.client.gui.GuiYesNo) ItemBowCavenic(cavern.item.ItemBowCavenic) CavelandConfig(cavern.config.CavelandConfig) ITextComponent(net.minecraft.util.text.ITextComponent) Strings(com.google.common.base.Strings) ItemStack(net.minecraft.item.ItemStack) Lists(com.google.common.collect.Lists) RenderGameOverlayEvent(net.minecraftforge.client.event.RenderGameOverlayEvent) Minecraft(net.minecraft.client.Minecraft) OnConfigChangedEvent(net.minecraftforge.fml.client.event.ConfigChangedEvent.OnConfigChangedEvent) FOVUpdateEvent(net.minecraftforge.client.event.FOVUpdateEvent) MinerRank(cavern.stats.MinerRank) SideOnly(net.minecraftforge.fml.relauncher.SideOnly) HugeCavernConfig(cavern.config.HugeCavernConfig) Entity(net.minecraft.entity.Entity) GeneralConfig(cavern.config.GeneralConfig) MirageWorldsConfig(cavern.config.MirageWorldsConfig) Iterator(java.util.Iterator) TextFormatting(net.minecraft.util.text.TextFormatting) CaveDimensions(cavern.world.CaveDimensions) MinerStats(cavern.stats.MinerStats) IModGuiFactory(net.minecraftforge.fml.client.IModGuiFactory) KeyInputEvent(net.minecraftforge.fml.common.gameevent.InputEvent.KeyInputEvent) TextComponentString(net.minecraft.util.text.TextComponentString) IBlockState(net.minecraft.block.state.IBlockState) GuiScreen(net.minecraft.client.gui.GuiScreen) CaveniaConfig(cavern.config.CaveniaConfig) Material(net.minecraft.block.material.Material) EntityLivingBase(net.minecraft.entity.EntityLivingBase) GuiOpenEvent(net.minecraftforge.client.event.GuiOpenEvent) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent) RandomiteHelper(cavern.block.RandomiteHelper) IModGuiFactory(net.minecraftforge.fml.client.IModGuiFactory) GuiYesNo(net.minecraft.client.gui.GuiYesNo) GuiMainMenu(net.minecraft.client.gui.GuiMainMenu) DelayedToast(cavern.client.gui.toasts.DelayedToast) GuiScreen(net.minecraft.client.gui.GuiScreen) TextComponentString(net.minecraft.util.text.TextComponentString) Minecraft(net.minecraft.client.Minecraft) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 7 with GuiYesNo

use of net.minecraft.client.gui.GuiYesNo in project Wurst-MC-1.12 by Wurst-Imperium.

the class AltManagerScreen method actionPerformed.

@Override
public void actionPerformed(GuiButton button) {
    if (!button.enabled)
        return;
    if (button.id == 0) {
        // "Use" button
        Alt alt = altList.getSelectedAlt();
        if (alt.isCracked()) {
            LoginManager.changeCrackedName(alt.getEmail());
            mc.displayGuiScreen(prevScreen);
        } else {
            String reply = LoginManager.login(alt.getEmail(), alt.getPassword());
            if (reply.isEmpty()) {
                mc.displayGuiScreen(prevScreen);
                alt.setChecked(mc.session.getUsername());
                ConfigFiles.ALTS.save();
            } else
                errorTimer = 8;
        }
    } else if (button.id == 1)
        // "Direct Login" button
        mc.displayGuiScreen(new DirectLoginScreen(this));
    else if (button.id == 2)
        // "Add" button
        mc.displayGuiScreen(new AddAltScreen(this));
    else if (button.id == 3) {
        // "Star" button
        Alt alt = altList.getSelectedAlt();
        alt.setStarred(!alt.isStarred());
        GuiAltList.sortAlts();
        ConfigFiles.ALTS.save();
    } else if (button.id == 4) {
        // "Edit" button
        Alt alt = altList.getSelectedAlt();
        mc.displayGuiScreen(new EditAltScreen(this, alt));
    } else if (button.id == 5)
        // "Delete" button
        mc.displayGuiScreen(new GuiYesNo(this, "Are you sure you want to remove this alt?", "\"" + altList.getSelectedAlt().getNameOrEmail() + "\" will be lost forever! (A long time!)", "Delete", "Cancel", 1));
    else if (button.id == 6)
        // "Cancel" button
        mc.displayGuiScreen(prevScreen);
    else if (button.id == 7)
        // "Import Alts" button
        new Thread(() -> {
            JFileChooser fileChooser = new JFileChooser(WurstFolders.MAIN.toFile()) {

                @Override
                protected JDialog createDialog(Component parent) throws HeadlessException {
                    JDialog dialog = super.createDialog(parent);
                    dialog.setAlwaysOnTop(true);
                    return dialog;
                }
            };
            fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
            fileChooser.setAcceptAllFileFilterUsed(false);
            fileChooser.addChoosableFileFilter(new FileNameExtensionFilter("TXT file (username:password)", "txt"));
            if (fileChooser.showOpenDialog(FrameHook.getFrame()) == JFileChooser.APPROVE_OPTION)
                try {
                    File file = fileChooser.getSelectedFile();
                    BufferedReader load = new BufferedReader(new FileReader(file));
                    for (String line = ""; (line = load.readLine()) != null; ) {
                        String[] data = line.split(":");
                        if (data.length != 2)
                            continue;
                        GuiAltList.alts.add(new Alt(data[0], data[1], null));
                    }
                    load.close();
                    GuiAltList.sortAlts();
                    ConfigFiles.ALTS.save();
                } catch (IOException e) {
                    e.printStackTrace();
                    MiscUtils.simpleError(e, fileChooser);
                }
        }).start();
}
Also used : GuiYesNo(net.minecraft.client.gui.GuiYesNo) HeadlessException(java.awt.HeadlessException) Alt(net.wurstclient.altmanager.Alt) IOException(java.io.IOException) FileNameExtensionFilter(javax.swing.filechooser.FileNameExtensionFilter) JFileChooser(javax.swing.JFileChooser) BufferedReader(java.io.BufferedReader) FileReader(java.io.FileReader) Component(java.awt.Component) File(java.io.File) JDialog(javax.swing.JDialog)

Example 8 with GuiYesNo

use of net.minecraft.client.gui.GuiYesNo in project Wurst-MC-1.12 by Wurst-Imperium.

the class KeybindManagerScreen method actionPerformed.

@Override
protected void actionPerformed(GuiButton button) throws IOException {
    if (!button.enabled)
        return;
    switch(button.id) {
        case 0:
            // Add
            mc.displayGuiScreen(new KeybindEditorScreen(this));
            break;
        case 1:
            // Edit
            Keybind keybind = WurstClient.INSTANCE.getKeybinds().get(listGui.selectedSlot);
            mc.displayGuiScreen(new KeybindEditorScreen(this, keybind.getKey(), keybind.getCommands()));
            break;
        case 2:
            // Remove
            Keybind keybind1 = WurstClient.INSTANCE.getKeybinds().get(listGui.selectedSlot);
            WurstClient.INSTANCE.getKeybinds().remove(keybind1.getKey());
            break;
        case 3:
            // Back
            mc.displayGuiScreen(prevScreen);
            break;
        case 4:
            // Reset Keybinds
            mc.displayGuiScreen(new GuiYesNo(this, "Are you sure you want to reset your keybinds?", "This cannot be undone!", 0));
            break;
    }
}
Also used : GuiYesNo(net.minecraft.client.gui.GuiYesNo) Keybind(net.wurstclient.keybinds.KeybindList.Keybind)

Example 9 with GuiYesNo

use of net.minecraft.client.gui.GuiYesNo in project DynamicSurroundings by OreCruncher.

the class PresetsConfigGui method actionPerformed.

@Override
protected void actionPerformed(@Nonnull final GuiButton button) throws IOException {
    PresetInfo pi = this.selectedPreset != -1 ? this.presets.get(this.selectedPreset) : null;
    switch(button.id) {
        case ID_DONE:
            this.mc.displayGuiScreen(this.parentScreen);
            break;
        case ID_APPLY:
            {
                final StringBuilder builder = new StringBuilder();
                builder.append(pi.getTitle());
                if (pi.isRestartRequired())
                    builder.append("\n\n").append(this.RESTART_REQUIRED_TEXT);
                final GuiYesNo yn = new GuiYesNo(this, this.APPLY_WARNING_TEXT, builder.toString(), ID_APPLY);
                this.mc.displayGuiScreen(yn);
            }
            break;
        case ID_CREATE:
            {
                pi = new PresetInfo();
                final PresetInfoModifyGui gui = new PresetInfoModifyGui(this, pi, false, ID_CREATE);
                this.mc.displayGuiScreen(gui);
            }
            break;
        case ID_EDIT:
            {
                final PresetInfoModifyGui gui = new PresetInfoModifyGui(this, pi, true, ID_EDIT);
                this.mc.displayGuiScreen(gui);
            }
            break;
        case ID_SAVE:
            {
                final GuiYesNo yn = new GuiYesNo(this, this.SAVE_WARNING_TEXT, pi.getTitle(), ID_SAVE);
                this.mc.displayGuiScreen(yn);
            }
            break;
        case ID_DELETE:
            {
                final GuiYesNo yn = new GuiYesNo(this, this.DELETE_WARNING_TEXT, pi.getTitle(), ID_DELETE);
                this.mc.displayGuiScreen(yn);
            }
            break;
        case ID_REFRESH:
            reload();
            break;
        case ID_PREV_PAGE:
            if (this.currentPage > 0) {
                this.currentPage--;
                setPresetButtonText();
            }
            break;
        case ID_NEXT_PAGE:
            if (this.currentPage < this.maxPage) {
                this.currentPage++;
                setPresetButtonText();
            }
            break;
        default:
            // Handle selection of a preset button
            final int buttonMashed = button.id - ID_PRESET_BASE;
            if (buttonMashed < 0 || buttonMashed >= MAX_PRESETS_PAGE) {
                super.actionPerformed(button);
            } else {
                // A preset was hit!
                if (this.selectedPreset != -1) {
                    // We have a preset to clear. If it's in the current range
                    // we need to toggle.
                    final int low = this.currentPage * MAX_PRESETS_PAGE;
                    final int high = low + MAX_PRESETS_PAGE;
                    if (this.selectedPreset >= low && this.selectedPreset < high) {
                        // It's in range
                        final int idx = this.selectedPreset % MAX_PRESETS_PAGE;
                        this.presetButtons.get(idx).enabled = true;
                    }
                }
                this.selectedPreset = this.currentPage * MAX_PRESETS_PAGE + buttonMashed;
                this.presetButtons.get(buttonMashed).enabled = false;
                updateButtonState();
            }
    }
}
Also used : PresetInfo(org.blockartistry.Presets.data.PresetInfo) GuiYesNo(net.minecraft.client.gui.GuiYesNo)

Example 10 with GuiYesNo

use of net.minecraft.client.gui.GuiYesNo in project Minestuck by mraof.

the class GuiCaptchaDeck method actionPerformed.

@Override
protected void actionPerformed(GuiButton button) {
    if (button == this.modusButton && !container.inventory.getStackInSlot(0).isEmpty()) {
        ItemStack stack = container.inventory.getStackInSlot(0);
        if (!(stack.getItem() instanceof ItemCaptchaCard)) {
            Modus newModus = CaptchaDeckHandler.createInstance(CaptchaDeckHandler.getType(stack), Side.CLIENT);
            if (newModus != null && CaptchaDeckHandler.clientSideModus != null && newModus.getClass() != CaptchaDeckHandler.clientSideModus.getClass() && !newModus.canSwitchFrom(CaptchaDeckHandler.clientSideModus)) {
                mc.currentScreen = new GuiYesNo(this, I18n.format("gui.emptySylladex1"), I18n.format("gui.emptySylladex2"), 0) {

                    @Override
                    public void onGuiClosed() {
                        mc.currentScreen = (GuiScreen) parentScreen;
                        mc.player.closeScreen();
                    }
                };
                mc.currentScreen.setWorldAndResolution(mc, width, height);
                return;
            }
        }
        MinestuckChannelHandler.sendToServer(MinestuckPacket.makePacket(Type.CAPTCHA, CaptchaDeckPacket.MODUS));
    } else if (button == this.sylladexMap && CaptchaDeckHandler.clientSideModus != null) {
        mc.player.connection.sendPacket(new CPacketCloseWindow(mc.player.openContainer.windowId));
        mc.player.inventory.setItemStack(ItemStack.EMPTY);
        mc.displayGuiScreen(CaptchaDeckHandler.clientSideModus.getGuiHandler());
        mc.player.openContainer = mc.player.inventoryContainer;
    }
}
Also used : Modus(com.mraof.minestuck.inventory.captchalouge.Modus) GuiYesNo(net.minecraft.client.gui.GuiYesNo) ItemCaptchaCard(com.mraof.minestuck.item.ItemCaptchaCard) GuiScreen(net.minecraft.client.gui.GuiScreen) CPacketCloseWindow(net.minecraft.network.play.client.CPacketCloseWindow) ItemStack(net.minecraft.item.ItemStack)

Aggregations

GuiYesNo (net.minecraft.client.gui.GuiYesNo)10 IOException (java.io.IOException)2 GuiMainMenu (net.minecraft.client.gui.GuiMainMenu)2 CavernAPI (cavern.api.CavernAPI)1 IIceEquipment (cavern.api.IIceEquipment)1 RandomiteHelper (cavern.block.RandomiteHelper)1 CaveKeyBindings (cavern.client.CaveKeyBindings)1 GuiDownloadCaveTerrain (cavern.client.gui.GuiDownloadCaveTerrain)1 GuiLoadCaveTerrain (cavern.client.gui.GuiLoadCaveTerrain)1 GuiMiningRecords (cavern.client.gui.GuiMiningRecords)1 DelayedToast (cavern.client.gui.toasts.DelayedToast)1 AquaCavernConfig (cavern.config.AquaCavernConfig)1 CavelandConfig (cavern.config.CavelandConfig)1 CaveniaConfig (cavern.config.CaveniaConfig)1 CavernConfig (cavern.config.CavernConfig)1 Config (cavern.config.Config)1 DisplayConfig (cavern.config.DisplayConfig)1 GeneralConfig (cavern.config.GeneralConfig)1 HugeCavernConfig (cavern.config.HugeCavernConfig)1 MiningAssistConfig (cavern.config.MiningAssistConfig)1