net.minecraft.client.gui.widget.AbstractButtonWidget Java Examples

The following examples show how to use net.minecraft.client.gui.widget.AbstractButtonWidget. 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: TitleScreenMixin.java    From Wurst7 with GNU General Public License v3.0 6 votes vote down vote up
@Inject(at = {@At("RETURN")}, method = {"initWidgetsNormal(II)V"})
private void onInitWidgetsNormal(int y, int spacingY, CallbackInfo ci)
{
	if(!WurstClient.INSTANCE.isEnabled())
		return;
	
	addButton(new ButtonWidget(width / 2 + 2, y + spacingY * 2, 98, 20,
		new LiteralText("Alt Manager"),
		b -> client.openScreen(new AltManagerScreen(this,
			WurstClient.INSTANCE.getAltManager()))));
	
	for(AbstractButtonWidget button : buttons)
	{
		if(!button.getMessage().getString()
			.equals(I18n.translate("menu.online")))
			continue;
		
		button.setWidth(98);
	}
}
 
Example #2
Source File: StatsScreenMixin.java    From Wurst7 with GNU General Public License v3.0 6 votes vote down vote up
@Inject(at = {@At("TAIL")}, method = {"createButtons()V"})
private void onCreateButtons(CallbackInfo ci)
{
	ButtonWidget toggleWurstButton = new ButtonWidget(width / 2 - 152,
		height - 28, 150, 20, new LiteralText(""), this::toggleWurst);
	
	updateWurstButtonText(toggleWurstButton);
	addButton(toggleWurstButton);
	
	for(AbstractButtonWidget button : buttons)
	{
		if(!button.getMessage().getString()
			.equals(I18n.translate("gui.done")))
			continue;
		
		button.x = width / 2 + 2;
		button.setWidth(150);
	}
}
 
Example #3
Source File: CleanUpScreen.java    From Wurst7 with GNU General Public License v3.0 6 votes vote down vote up
private void renderButtonTooltip(MatrixStack matrixStack, int mouseX,
	int mouseY)
{
	for(AbstractButtonWidget button : buttons)
	{
		if(!button.isHovered() || !(button instanceof CleanUpButton))
			continue;
		
		CleanUpButton woButton = (CleanUpButton)button;
		if(woButton.tooltip.isEmpty())
			continue;
		
		renderTooltip(matrixStack, woButton.tooltip, mouseX, mouseY);
		break;
	}
}
 
Example #4
Source File: WurstOptionsScreen.java    From Wurst7 with GNU General Public License v3.0 6 votes vote down vote up
private void renderButtonTooltip(MatrixStack matrixStack, int mouseX,
	int mouseY)
{
	for(AbstractButtonWidget button : buttons)
	{
		if(!button.isHovered() || !(button instanceof WurstOptionsButton))
			continue;
		
		WurstOptionsButton woButton = (WurstOptionsButton)button;
		if(woButton.tooltip.isEmpty())
			continue;
		
		renderTooltip(matrixStack, woButton.tooltip, mouseX, mouseY);
		break;
	}
}
 
Example #5
Source File: GameMenuScreenMixin.java    From Wurst7 with GNU General Public License v3.0 5 votes vote down vote up
private boolean isFeedbackOrBugReportButton(Element element)
{
	if(element == null || !(element instanceof AbstractButtonWidget))
		return false;
	
	AbstractButtonWidget button = (AbstractButtonWidget)element;
	String message = button.getMessage().getString();
	
	return message != null
		&& (message.equals(I18n.translate("menu.sendFeedback"))
			|| message.equals(I18n.translate("menu.reportBugs")));
}
 
Example #6
Source File: WLabeledSlider.java    From LibGui with MIT License 5 votes vote down vote up
@Environment(EnvType.CLIENT)
private void drawButton(int x, int y, int state, int width) {
	float px = 1 / 256f;
	float buttonLeft = 0 * px;
	float buttonTop = (46 + (state * 20)) * px;
	int halfWidth = width / 2;
	if (halfWidth > 198) halfWidth = 198;
	float buttonWidth = halfWidth * px;
	float buttonHeight = 20 * px;
	float buttonEndLeft = (200 - halfWidth) * px;

	ScreenDrawing.texturedRect(x, y, halfWidth, 20, AbstractButtonWidget.WIDGETS_LOCATION, buttonLeft, buttonTop, buttonLeft + buttonWidth, buttonTop + buttonHeight, 0xFFFFFFFF);
	ScreenDrawing.texturedRect(x + halfWidth, y, halfWidth, 20, AbstractButtonWidget.WIDGETS_LOCATION, buttonEndLeft, buttonTop, 200 * px, buttonTop + buttonHeight, 0xFFFFFFFF);
}
 
Example #7
Source File: WButton.java    From LibGui with MIT License 5 votes vote down vote up
@Override
public void paint(MatrixStack matrices, int x, int y, int mouseX, int mouseY) {
	boolean hovered = (mouseX>=0 && mouseY>=0 && mouseX<getWidth() && mouseY<getHeight());
	int state = 1; //1=regular. 2=hovered. 0=disabled.
	if (!enabled) state = 0;
	else if (hovered || isFocused()) state = 2;
	
	float px = 1/256f;
	float buttonLeft = 0 * px;
	float buttonTop = (46 + (state*20)) * px;
	int halfWidth = getWidth()/2;
	if (halfWidth>198) halfWidth=198;
	float buttonWidth = halfWidth*px;
	float buttonHeight = 20*px;
	
	float buttonEndLeft = (200-(getWidth()/2)) * px;
	
	ScreenDrawing.texturedRect(x, y, getWidth()/2, 20, AbstractButtonWidget.WIDGETS_LOCATION, buttonLeft, buttonTop, buttonLeft+buttonWidth, buttonTop+buttonHeight, 0xFFFFFFFF);
	ScreenDrawing.texturedRect(x+(getWidth()/2), y, getWidth()/2, 20, AbstractButtonWidget.WIDGETS_LOCATION, buttonEndLeft, buttonTop, 200*px, buttonTop+buttonHeight, 0xFFFFFFFF);
	
	if (label!=null) {
		int color = 0xE0E0E0;
		if (!enabled) {
			color = 0xA0A0A0;
		} /*else if (hovered) {
			color = 0xFFFFA0;
		}*/
		
		ScreenDrawing.drawStringWithShadow(matrices, label, alignment, x, y + ((20 - 8) / 2), width, color); //LibGuiClient.config.darkMode ? darkmodeColor : color);
	}
}
 
Example #8
Source File: MixinScreen.java    From Sandbox with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public List<AbstractButtonWidget> getButtons() {
    return buttons;
}
 
Example #9
Source File: MixinScreen.java    From Sandbox with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Shadow
protected abstract <T extends AbstractButtonWidget> T addButton(T abstractButtonWidget_1);
 
Example #10
Source File: SandboxTitleScreen.java    From Sandbox with GNU Lesser General Public License v3.0 4 votes vote down vote up
public void render(int int_1, int int_2, float float_1) {
    if (this.backgroundFadeStart == 0L && this.doBackgroundFade) {
        this.backgroundFadeStart = Util.getMeasuringTimeMs();
    }

    float float_2 = this.doBackgroundFade ? (float) (Util.getMeasuringTimeMs() - this.backgroundFadeStart) / 1000.0F : 1.0F;
    fill(0, 0, this.width, this.height, -1);
    this.backgroundRenderer.render(float_1, MathHelper.clamp(float_2, 0.0F, 1.0F));
    int int_4 = this.width / 2 - 137;
    this.minecraft.getTextureManager().bindTexture(PANORAMA_OVERLAY);
    GlStateManager.enableBlend();
    GlStateManager.blendFunc(GlStateManager.SrcFactor.SRC_ALPHA.value, GlStateManager.DstFactor.ONE_MINUS_SRC_ALPHA.value);
    GlStateManager.color4f(1.0F, 1.0F, 1.0F, this.doBackgroundFade ? (float) MathHelper.ceil(MathHelper.clamp(float_2, 0.0F, 1.0F)) : 1.0F);
    blit(0, 0, this.width, this.height, 0.0F, 0.0F, 16, 128, 16, 128);
    float float_3 = this.doBackgroundFade ? MathHelper.clamp(float_2 - 1.0F, 0.0F, 1.0F) : 1.0F;
    int int_6 = MathHelper.ceil(float_3 * 255.0F) << 24;
    if ((int_6 & -67108864) != 0) {
        this.minecraft.getTextureManager().bindTexture(MINECRAFT_TITLE_TEXTURE);
        GlStateManager.color4f(1.0F, 1.0F, 1.0F, float_3);
        if (this.field_17776) {
            this.blit(int_4 + 0, 30, 0, 0, 99, 44);
            this.blit(int_4 + 99, 30, 129, 0, 27, 44);
            this.blit(int_4 + 99 + 26, 30, 126, 0, 3, 44);
            this.blit(int_4 + 99 + 26 + 3, 30, 99, 0, 26, 44);
            this.blit(int_4 + 155, 30, 0, 45, 155, 44);
        } else {
            this.blit(int_4 + 0, 30, 0, 0, 155, 44);
            this.blit(int_4 + 155, 30, 0, 45, 155, 44);
        }

        this.minecraft.getTextureManager().bindTexture(EDITION_TITLE_TEXTURE);
        blit(int_4 + 88, 67, 0.0F, 0.0F, 98, 14, 128, 16);
        if (this.splashText != null) {
            GlStateManager.pushMatrix();
            GlStateManager.translatef((float) (this.width / 2 + 90), 70.0F, 0.0F);
            GlStateManager.rotatef(-20.0F, 0.0F, 0.0F, 1.0F);
            float float_4 = 1.8F - MathHelper.abs(MathHelper.sin((float) (Util.getMeasuringTimeMs() % 1000L) / 1000.0F * 6.2831855F) * 0.1F);
            float_4 = float_4 * 100.0F / (float) (this.font.getStringWidth(this.splashText) + 32);
            GlStateManager.scalef(float_4, float_4, float_4);
            this.drawCenteredString(this.font, this.splashText, 0, -8, 16776960 | int_6);
            GlStateManager.popMatrix();
        }

        String string_1 = "Minecraft " + SharedConstants.getGameVersion().getName();
        if (this.minecraft.isDemo()) {
            string_1 = string_1 + " Demo";
        } else {
            string_1 = string_1 + ("release".equalsIgnoreCase(this.minecraft.getVersionType()) ? "" : "/" + this.minecraft.getVersionType());
        }

        this.drawString(this.font, string_1, 2, this.height - 10, 16777215 | int_6);
        this.drawString(this.font, "Copyright Mojang AB. Do not distribute!", this.copyrightTextX, this.height - 10, 16777215 | int_6);
        if (int_1 > this.copyrightTextX && int_1 < this.copyrightTextX + this.copyrightTextWidth && int_2 > this.height - 10 && int_2 < this.height) {
            fill(this.copyrightTextX, this.height - 1, this.copyrightTextX + this.copyrightTextWidth, this.height, 16777215 | int_6);
        }

        if (this.warning != null) {
            this.warning.render(int_6);
        }

        Iterator var11 = this.buttons.iterator();

        while (var11.hasNext()) {
            AbstractButtonWidget abstractButtonWidget_1 = (AbstractButtonWidget) var11.next();
            abstractButtonWidget_1.setAlpha(float_3);
        }

        super.render(int_1, int_2, float_1);

    }
}
 
Example #11
Source File: MixinScreen.java    From patchwork-api with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Shadow
protected abstract <T extends AbstractButtonWidget> T addButton(T button);
 
Example #12
Source File: GuiScreenEvent.java    From patchwork-api with GNU Lesser General Public License v2.1 4 votes vote down vote up
public Post(Screen gui, List<AbstractButtonWidget> list, Consumer<AbstractButtonWidget> add, Consumer<AbstractButtonWidget> remove) {
	super(gui, list, add, remove);
}
 
Example #13
Source File: GuiScreenEvent.java    From patchwork-api with GNU Lesser General Public License v2.1 4 votes vote down vote up
public Pre(Screen gui, List<AbstractButtonWidget> list, Consumer<AbstractButtonWidget> add, Consumer<AbstractButtonWidget> remove) {
	super(gui, list, add, remove);
}
 
Example #14
Source File: GuiScreenEvent.java    From patchwork-api with GNU Lesser General Public License v2.1 4 votes vote down vote up
public void removeWidget(AbstractButtonWidget button) {
	remove.accept(button);
}
 
Example #15
Source File: GuiScreenEvent.java    From patchwork-api with GNU Lesser General Public License v2.1 4 votes vote down vote up
public void addWidget(AbstractButtonWidget button) {
	add.accept(button);
}
 
Example #16
Source File: GuiScreenEvent.java    From patchwork-api with GNU Lesser General Public License v2.1 4 votes vote down vote up
/**
 * Unmodifiable reference to the list of buttons on the {@link #gui}.
 */
public List<AbstractButtonWidget> getWidgetList() {
	return list;
}
 
Example #17
Source File: GuiScreenEvent.java    From patchwork-api with GNU Lesser General Public License v2.1 4 votes vote down vote up
public InitGuiEvent(Screen gui, List<AbstractButtonWidget> list, Consumer<AbstractButtonWidget> add, Consumer<AbstractButtonWidget> remove) {
	super(gui);
	this.list = Collections.unmodifiableList(list);
	this.add = add;
	this.remove = remove;
}
 
Example #18
Source File: ISandboxScreen.java    From Sandbox with GNU Lesser General Public License v3.0 votes vote down vote up
List<AbstractButtonWidget> getButtons();