net.minecraft.client.gui.screen.ConfirmScreen Java Examples

The following examples show how to use net.minecraft.client.gui.screen.ConfirmScreen. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: KeybindManagerScreen.java    From Wurst7 with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void init()
{
	listGui = new ListGui(client, width, height, 36, height - 56, 30);
	
	addButton(addButton = new ButtonWidget(width / 2 - 102, height - 52,
		100, 20, new LiteralText("Add"),
		b -> client.openScreen(new KeybindEditorScreen(this))));
	
	addButton(editButton = new ButtonWidget(width / 2 + 2, height - 52, 100,
		20, new LiteralText("Edit"), b -> edit()));
	
	addButton(removeButton = new ButtonWidget(width / 2 - 102, height - 28,
		100, 20, new LiteralText("Remove"), b -> remove()));
	
	addButton(backButton = new ButtonWidget(width / 2 + 2, height - 28, 100,
		20, new LiteralText("Back"), b -> client.openScreen(prevScreen)));
	
	addButton(
		new ButtonWidget(8, 8, 100, 20, new LiteralText("Reset Keybinds"),
			b -> client.openScreen(new ConfirmScreen(confirmed -> {
				if(confirmed)
					WurstClient.INSTANCE.getKeybinds()
						.setKeybinds(KeybindList.DEFAULT_KEYBINDS);
				client.openScreen(this);
			}, new LiteralText(
				"Are you sure you want to reset your keybinds?"),
				new LiteralText("This cannot be undone!")))));
	
	addButton(new ButtonWidget(width - 108, 8, 100, 20,
		new LiteralText("Profiles..."),
		b -> client.openScreen(new KeybindProfilesScreen(this))));
}
 
Example #2
Source File: EditBlockListScreen.java    From Wurst7 with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void init()
{
	listGui = new ListGui(client, this, blockList.getBlockNames());
	
	blockNameField = new TextFieldWidget(client.textRenderer,
		width / 2 - 152, height - 55, 150, 18, new LiteralText(""));
	children.add(blockNameField);
	
	addButton(addButton = new ButtonWidget(width / 2 - 2, height - 56, 30,
		20, new LiteralText("Add"), b -> {
			blockList.add(blockToAdd);
			blockNameField.setText("");
		}));
	
	addButton(removeButton = new ButtonWidget(width / 2 + 52, height - 56,
		100, 20, new LiteralText("Remove Selected"),
		b -> blockList.remove(listGui.selected)));
	
	addButton(new ButtonWidget(width - 108, 8, 100, 20,
		new LiteralText("Reset to Defaults"),
		b -> client.openScreen(new ConfirmScreen(b2 -> {
			if(b2)
				blockList.resetToDefaults();
			client.openScreen(EditBlockListScreen.this);
		}, new LiteralText("Reset to Defaults"),
			new LiteralText("Are you sure?")))));
	
	addButton(
		doneButton = new ButtonWidget(width / 2 - 100, height - 28, 200, 20,
			new LiteralText("Done"), b -> client.openScreen(prevScreen)));
}
 
Example #3
Source File: SelectFileScreen.java    From Wurst7 with GNU General Public License v3.0 5 votes vote down vote up
private void askToConfirmReset()
{
	LiteralText title = new LiteralText("Reset Folder");
	
	LiteralText message = new LiteralText(
		"This will empty the '" + setting.getFolder().getFileName()
			+ "' folder and then re-generate the default files.\n"
			+ "Are you sure you want to do this?");
	
	client.openScreen(
		new ConfirmScreen(c -> confirmReset(c), title, message));
}
 
Example #4
Source File: EditItemListScreen.java    From Wurst7 with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void init()
{
	listGui = new ListGui(client, this, itemList.getItemNames());
	
	itemNameField = new TextFieldWidget(client.textRenderer,
		width / 2 - 152, height - 55, 150, 18, new LiteralText(""));
	children.add(itemNameField);
	
	addButton(addButton = new ButtonWidget(width / 2 - 2, height - 56, 30,
		20, new LiteralText("Add"), b -> {
			itemList.add(itemToAdd);
			itemNameField.setText("");
		}));
	
	addButton(removeButton = new ButtonWidget(width / 2 + 52, height - 56,
		100, 20, new LiteralText("Remove Selected"),
		b -> itemList.remove(listGui.selected)));
	
	addButton(new ButtonWidget(width - 108, 8, 100, 20,
		new LiteralText("Reset to Defaults"),
		b -> client.openScreen(new ConfirmScreen(b2 -> {
			if(b2)
				itemList.resetToDefaults();
			client.openScreen(EditItemListScreen.this);
		}, new LiteralText("Reset to Defaults"),
			new LiteralText("Are you sure?")))));
	
	addButton(
		doneButton = new ButtonWidget(width / 2 - 100, height - 28, 200, 20,
			new LiteralText("Done"), b -> client.openScreen(prevScreen)));
}
 
Example #5
Source File: AltManagerScreen.java    From Wurst7 with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void init()
{
	listGui = new ListGui(client, this, altManager.getList());
	
	if(altManager.getList().isEmpty() && shouldAsk)
		client.openScreen(new ConfirmScreen(this::confirmGenerate,
			new LiteralText("Your alt list is empty."), new LiteralText(
				"Would you like some random alts to get started?")));
	
	addButton(useButton = new ButtonWidget(width / 2 - 154, height - 52,
		100, 20, new LiteralText("Use"), b -> pressUse()));
	
	addButton(new ButtonWidget(width / 2 - 50, height - 52, 100, 20,
		new LiteralText("Direct Login"),
		b -> client.openScreen(new DirectLoginScreen(this))));
	
	addButton(new ButtonWidget(width / 2 + 54, height - 52, 100, 20,
		new LiteralText("Add"),
		b -> client.openScreen(new AddAltScreen(this, altManager))));
	
	addButton(starButton = new ButtonWidget(width / 2 - 154, height - 28,
		75, 20, new LiteralText("Star"), b -> pressStar()));
	
	addButton(editButton = new ButtonWidget(width / 2 - 76, height - 28, 74,
		20, new LiteralText("Edit"), b -> pressEdit()));
	
	addButton(deleteButton = new ButtonWidget(width / 2 + 2, height - 28,
		74, 20, new LiteralText("Delete"), b -> pressDelete()));
	
	addButton(new ButtonWidget(width / 2 + 80, height - 28, 75, 20,
		new LiteralText("Cancel"), b -> client.openScreen(prevScreen)));
	
	addButton(new ButtonWidget(8, 8, 100, 20,
		new LiteralText("Import Alts"), b -> pressImportAlts()));
}
 
Example #6
Source File: AltManagerScreen.java    From Wurst7 with GNU General Public License v3.0 5 votes vote down vote up
private void pressDelete()
{
	LiteralText text =
		new LiteralText("Are you sure you want to remove this alt?");
	
	String altName = listGui.getSelectedAlt().getNameOrEmail();
	LiteralText message = new LiteralText(
		"\"" + altName + "\" will be lost forever! (A long time!)");
	
	ConfirmScreen screen = new ConfirmScreen(this::confirmRemove, text,
		message, new LiteralText("Delete"), new LiteralText("Cancel"));
	client.openScreen(screen);
}
 
Example #7
Source File: Optifabric.java    From OptiFabric with Mozilla Public License 2.0 5 votes vote down vote up
public static void checkForErrors() {
	if (OptifabricError.hasError()) {
		ConfirmScreen confirmScreen = new ConfirmScreen(t -> {
			if (t) {
				Util.getOperatingSystem().open(OptifabricError.getErrorURL());
			} else {
				MinecraftClient.getInstance().scheduleStop();
			}
		}, new LiteralText(Formatting.RED + "There was an error loading OptiFabric!"), new LiteralText(OptifabricError.getError()), Formatting.GREEN + OptifabricError.getHelpButtonText(), Formatting.RED + "Close Game");

		MinecraftClient.getInstance().openScreen(confirmScreen);
	}
}
 
Example #8
Source File: MixinMultiplayerScreen.java    From ViaFabric with MIT License 4 votes vote down vote up
@Inject(method = "init", at = @At("TAIL"))
private void onInit(CallbackInfo ci) {
    protocolVersion = new TextFieldWidget(this.textRenderer, this.width / 2 + 88, 13, 65, 15, new TranslatableText("gui.protocol_version_field.name"));
    protocolVersion.setTextPredicate(new VersionFormatFilter());
    protocolVersion.setChangedListener((text) -> {
        protocolVersion.setSuggestion(null);
        int newVersion = ViaFabric.config.getClientSideVersion();
        validProtocol = true;
        try {
            newVersion = Integer.parseInt(text);
        } catch (NumberFormatException e) {
            ProtocolVersion closest = ProtocolVersion.getClosest(text);
            if (closest != null) {
                newVersion = closest.getId();
            } else {
                validProtocol = false;
                List<String> completions = ProtocolVersion.getProtocols().stream()
                        .map(ProtocolVersion::getName)
                        .flatMap(str -> Stream.concat(
                                Arrays.stream(str.split("-")),
                                Arrays.stream(new String[]{str})
                        ))
                        .distinct()
                        .filter(ver -> ver.startsWith(text))
                        .collect(Collectors.toList());
                if (completions.size() == 1) {
                    protocolVersion.setSuggestion(completions.get(0).substring(text.length()));
                }
            }
        }
        supportedProtocol = isSupported(newVersion);
        protocolVersion.setEditableColor(getTextColor());
        int finalNewVersion = newVersion;
        if (latestProtocolSave == null) latestProtocolSave = CompletableFuture.completedFuture(null);
        latestProtocolSave = latestProtocolSave.thenRunAsync(() -> {
            ViaFabric.config.setClientSideVersion(finalNewVersion);
            ViaFabric.config.saveConfig();
        }, ViaFabric.ASYNC_EXECUTOR);
    });
    int clientSideVersion = ViaFabric.config.getClientSideVersion();

    protocolVersion.setVisible(ViaFabric.config.isClientSideEnabled());

    protocolVersion.setText(ProtocolVersion.isRegistered(clientSideVersion)
            ? ProtocolVersion.getProtocol(clientSideVersion).getName()
            : Integer.toString(clientSideVersion));
    this.children.add(protocolVersion);

    enableClientSideViaVersion = new TexturedButtonWidget(this.width / 2 + 113, 10,
            40, 20, // Size
            0, 0, // Start pos of texture
            20, // v Hover offset
            new Identifier("viafabric:textures/gui/via_button.png"),
            64, 64, // Texture size
            button -> MinecraftClient.getInstance().openScreen(new ConfirmScreen(
                    answer -> {
                        MinecraftClient.getInstance().openScreen(this);
                        if (answer) {
                            ViaFabric.config.setClientSideEnabled(true);
                            ViaFabric.config.saveConfig();
                            protocolVersion.setVisible(true);
                            enableClientSideViaVersion.visible = false;
                        }
                    },
                    new TranslatableText("gui.enable_client_side.question"),
                    new TranslatableText("gui.enable_client_side.warning"),
                    new TranslatableText("gui.enable_client_side.enable"),
                    new TranslatableText("gui.cancel")
            )),
            new TranslatableText("gui.enable_client_side_button"));
    enableClientSideViaVersion.visible = !protocolVersion.isVisible();
    addButton(enableClientSideViaVersion);
}