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();
}
}
}
}
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();
}
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;
}
}
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();
}
}
}
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;
}
}
Aggregations