net.minecraftforge.fml.client.config.GuiUtils Java Examples

The following examples show how to use net.minecraftforge.fml.client.config.GuiUtils. 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: BaseEntry.java    From WearableBackpacks with MIT License 6 votes vote down vote up
public BaseEntry() {
	super(Direction.HORIZONTAL);
	setFillHorizontal();
	
	iconStatus = new GuiImage(16, 16, TEXTURE_CONFIG_ICONS);
	iconStatus.setCenteredVertical();
	
	label = new GuiLabel("");
	label.setCenteredVertical();
	label.setShadowDisabled();
	
	buttonUndo = new GuiButtonGlyph(DEFAULT_ENTRY_HEIGHT, DEFAULT_ENTRY_HEIGHT, GuiUtils.UNDO_CHAR, 1.0f);
	buttonUndo.setCenteredVertical();
	buttonUndo.setAction(this::undoChanges);
	
	buttonReset = new GuiButtonGlyph(DEFAULT_ENTRY_HEIGHT, DEFAULT_ENTRY_HEIGHT, GuiUtils.RESET_CHAR, 1.0f);
	buttonReset.setCenteredVertical();
	buttonReset.setAction(this::setToDefault);
}
 
Example #2
Source File: ItemTabInfo.java    From GregTech with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void renderHoverText(int posX, int posY, int xSize, int ySize, int guiWidth, int guiHeight, boolean isSelected, int mouseX, int mouseY) {
    String localizedText = I18n.format(nameLocale);
    Minecraft mc = Minecraft.getMinecraft();
    ScaledResolution resolution = new ScaledResolution(mc);
    GuiUtils.drawHoveringText(Lists.newArrayList(localizedText), mouseX, mouseY,
        resolution.getScaledWidth(), resolution.getScaledHeight(), -1, mc.fontRenderer);
}
 
Example #3
Source File: Widget.java    From GregTech with GNU Lesser General Public License v3.0 5 votes vote down vote up
@SideOnly(Side.CLIENT)
protected void drawHoveringText(ItemStack itemStack, List<String> tooltip, int maxTextWidth, int mouseX, int mouseY) {
    Minecraft mc = Minecraft.getMinecraft();
    GuiUtils.drawHoveringText(itemStack, tooltip, mouseX, mouseY,
         sizes.getScreenWidth(),
         sizes.getScreenHeight(), maxTextWidth, mc.fontRenderer);
}
 
Example #4
Source File: BaseEntry.java    From WearableBackpacks with MIT License 5 votes vote down vote up
@Override
public void draw(int mouseX, int mouseY, float partialTicks) {
	List<Status> status  = getStatus();
	Severity severity    = Status.getSeverity(status);
	List<String> tooltip = Status.getMessage(status);
	boolean isFine       = (severity == Severity.FINE);
	
	enableBlendAlphaStuffs();
	drawColoredRectARGB(16, -1, getWidth() - 12, getHeight() + 2, severity.backgroundColor);
	disableBlendAlphaStuffs();
	
	iconStatus.setTextureUV(severity.guiIconIndex * 16, 0);
	iconStatus.setTooltip(tooltip);
	
	if (hasLabel()) {
		String text = label.getText();
		if (text.startsWith(TextFormatting.ITALIC.toString())) text = text.substring(2);
		if (isChanged()) text = TextFormatting.ITALIC + text;
		label.setText(text);
		label.setColor(!isEnabled() ? GuiUtils.getColorCode('8', true)
		             : isFine       ? GuiUtils.getColorCode('7', true)
		                            : severity.foregroundColor);
	}
	
	buttonUndo.setEnabled(isChanged());
	buttonReset.setEnabled(!isDefault());
	
	super.draw(mouseX, mouseY, partialTicks);
}
 
Example #5
Source File: ProgressBar.java    From customstuff4 with GNU General Public License v3.0 5 votes vote down vote up
public void draw(ProgressBarSource progressSource)
{
    float progress = progressSource.getProgress(this.source);

    int w = direction.getWidth(width, progress);
    int h = direction.getHeight(height, progress);

    int offsetX = direction.getOffsetX(width, w);
    int offsetY = direction.getOffsetY(height, h);

    GuiUtils.drawTexturedModalRect(x + offsetX, y + offsetY, texX + offsetX, texY + offsetY, w, h, 0f);
}
 
Example #6
Source File: ComponentRenderer.java    From AgriCraft with MIT License 5 votes vote down vote up
public static void renderComponentProgressBar(AgriGuiWrapper gui, GuiComponent<Supplier<Integer>> component) {
    final int width = component.getBounds().width;
    final int height = component.getBounds().height;
    final double progress = MathHelper.inRange(component.getComponent().get(), 0.0, 100.0);
    GuiUtils.drawContinuousTexturedBox(WIDGETS, 0, 0, 100, 25, width, height, 16, 16, 2, 0);
    GuiUtils.drawContinuousTexturedBox(WIDGETS, 0, 0, 125, 25, (int) ((width * progress) / 100), height, 16, 16, 2, 0);
}
 
Example #7
Source File: ScreenEntityEntry.java    From WearableBackpacks with MIT License 5 votes vote down vote up
@Override
public void draw(int mouseX, int mouseY, float partialTicks) {
	long currentTime = Minecraft.getSystemTime();
	if (currentTime > _lastUpdateTime + UPDATE_TIMESPAN) {
		updateBackpackItem();
		_lastUpdateTime = currentTime;
	}
	
	setTextAndBorderColorIf(fieldChance.getText().isEmpty(), fieldChance, Severity.ERROR.foregroundColor);
	
	int backpackColor = fieldBackpack.getText().isEmpty() ? Severity.ERROR.foregroundColor
		: itemBackpack.getStack().isEmpty() ? Severity.WARN.foregroundColor
		: !(itemBackpack.getStack().getItem() instanceof ItemBackpack) ? Severity.ERROR.foregroundColor
		: -1;
	setTextAndBorderColorIf((backpackColor != -1), fieldBackpack, backpackColor);
	if (backpackColor != -1) itemBackpack.setBorderColor(backpackColor);
	else itemBackpack.resetBorderColor();
	
	boolean colorOn = switchColorOn.isSwitchOn();
	boolean valid = !colorOn ||
		(fieldColorMin.getText().length() == 6) &&
		(fieldColorMax.getText().length() == 6) &&
		new ColorRange(Integer.parseInt(fieldColorMin.getText(), 16),
		               Integer.parseInt(fieldColorMax.getText(), 16)).isValid();
	setTextAndBorderColorIf(!valid, fieldColorMin, Severity.ERROR.foregroundColor);
	setTextAndBorderColorIf(!valid, fieldColorMax, Severity.ERROR.foregroundColor);
	int color = !colorOn ? GuiUtils.getColorCode('8', true)
	             : valid ? GuiUtils.getColorCode('7', true)
	                     : Severity.ERROR.foregroundColor;
	labelColor.setColor(color);
	labelColorCenter.setColor(color);
	
	super.draw(mouseX, mouseY, partialTicks);
}
 
Example #8
Source File: EntryValueEffectOpacity.java    From WearableBackpacks with MIT License 5 votes vote down vote up
private static void renderEffect(int x, int y, int width, int height, float opacity) {
	if (opacity <= 0) return;
	Minecraft mc = Minecraft.getMinecraft();
	float animProgress = Minecraft.getSystemTime() / 400.0F;
	
	int color = 0xFF8040CC;
	float r = (color >> 16 & 0xFF) / 255.0F;
	float g = (color >> 8 & 0xFF) / 255.0F;
	float b = (color & 0xFF) / 255.0F;
	GlStateManager.color(r, g, b, opacity * 0.6F);
	
	mc.getTextureManager().bindTexture(ENCHANTED_ITEM_GLINT);
	
	GlStateManager.enableBlend();
	GlStateManager.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE);
	GlStateManager.enableAlpha();
	GlStateManager.alphaFunc(GL11.GL_ALWAYS, 0.0F);
	
	for (int i = 0; i < 2; ++i) {
		GlStateManager.matrixMode(GL11.GL_TEXTURE);
		GlStateManager.loadIdentity();
		GlStateManager.rotate(30.0F - i * 60.0F, 0.0F, 0.0F, 1.0F);
		GlStateManager.translate(0.0F, animProgress * (0.001F + i * 0.003F) * 20.0F, 0.0F);
		GlStateManager.matrixMode(GL11.GL_MODELVIEW);
		GuiUtils.drawTexturedModalRect(x, y, 0, 0, width, height, 0);
	}
	
	GlStateManager.matrixMode(GL11.GL_TEXTURE);
	GlStateManager.loadIdentity();
	GlStateManager.matrixMode(GL11.GL_MODELVIEW);
	
	GlStateManager.alphaFunc(GL11.GL_GREATER, 0.1F);
	GlStateManager.disableAlpha();
	GlStateManager.blendFunc(GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
	GlStateManager.disableBlend();
}
 
Example #9
Source File: GuiSlider.java    From WearableBackpacks with MIT License 5 votes vote down vote up
/** Draws the slider bar. */
protected void drawSliderBar(boolean isHighlighted, float partialTicks) {
	int sliderSize = getSliderSize();
	boolean slideHorizontal = directions.contains(Direction.HORIZONTAL);
	boolean slideVertical   = directions.contains(Direction.VERTICAL);
	int x = slideHorizontal ? (int)((getWidth()  - sliderSize) * getSliderRawX()) : 0;
	int y = slideVertical   ? (int)((getHeight() - sliderSize) * getSliderRawY()) : 0;
	int w = slideHorizontal ? sliderSize : getWidth();
	int h = slideVertical   ? sliderSize : getHeight();
	int ty = isEnabled() ? 66 : 46;
	GuiUtils.drawContinuousTexturedBox(GuiButton.BUTTON_TEX, x, y, 0, ty, w, h,
	                                   DEFAULT_WIDTH, DEFAULT_HEIGHT, 2, 3, 2, 2, 0);
}
 
Example #10
Source File: GuiButton.java    From WearableBackpacks with MIT License 5 votes vote down vote up
/** Draws the actual button texture. */
protected void drawButtonBackground(boolean isHighlighted, float partialTicks) {
	int buttonIndex = !isEnabled() ? 0
	                : !isHighlighted ? 1
	                : 2;
	int ty = 46 + buttonIndex * 20;
	GuiUtils.drawContinuousTexturedBox(BUTTON_TEX, 0, 0, 0, ty, getWidth(), getHeight(),
	                                   DEFAULT_WIDTH, DEFAULT_HEIGHT, 2, 3, 2, 2, 0);
}
 
Example #11
Source File: GuiElementBase.java    From WearableBackpacks with MIT License 5 votes vote down vote up
/** Draws this element's tooltip on the screen. Rendering and mouse
 *  position are global, not relative to this element's position. */
public void drawTooltip(int mouseX, int mouseY, int screenWidth, int screenHeight, float partialTicks) {
	if (!hasTooltip()) return;
	GuiUtils.drawHoveringText(getTooltip(),
		mouseX, mouseY, screenWidth, screenHeight,
		300, getFontRenderer());
}
 
Example #12
Source File: EntryListEntities.java    From WearableBackpacks with MIT License 5 votes vote down vote up
@Override
public void setValue(BackpackEntityEntry value) {
	_value = value;
	
	Optional<EntityEntry> entry = getEntityEntry(value.entityID);
	_knownEntity      = entry.isPresent();
	Severity severity = Status.getSeverity(getStatus());
	boolean isFine    = (severity == Severity.FINE);
	
	int numEntries = value.getEntries().size();
	String entriesTextKey = "config." + WearableBackpacks.MOD_ID + ".entity.entry";
	// First we try to translate "[...].entity.entry.<num>".
	String entriesText = I18n.format(entriesTextKey + "." + numEntries);
	if (entriesText.equals(entriesTextKey + "." + numEntries))
		// If not found, use "[...].entity.entry" instead.
		entriesText = I18n.format(entriesTextKey, numEntries);
	// ... I miss C#'s ?? operator :(
	
	buttonMove.setEnabled(!value.isDefault);
	buttonRemove.setEnabled(!value.isDefault);
	
	labelName.setText(getEntityEntryName(entry, value.entityID));
	labelName.setColor(value.isDefault ? GuiUtils.getColorCode('8', true)
	                 : isFine          ? GuiUtils.getColorCode('7', true)
	                                   : severity.foregroundColor);
	
	buttonEdit.setText(entriesText);
	if (!_knownEntity) buttonEdit.setTextColor(Severity.WARN.foregroundColor);
	else buttonEdit.unsetTextColor();
}
 
Example #13
Source File: Status.java    From WearableBackpacks with MIT License 4 votes vote down vote up
private Severity(char chr, int background) {
	colorChar = chr;
	foregroundColor = 0xFF000000 | GuiUtils.getColorCode(chr, true);
	backgroundColor = background;
	guiIconIndex = ordinal();
}
 
Example #14
Source File: BaseConfigScreen.java    From WearableBackpacks with MIT License 4 votes vote down vote up
public BaseConfigScreen(GuiScreen parentScreen, String... titleLines) {
	this.parentScreen = parentScreen;
	
	layoutMain = new GuiLayout(Direction.VERTICAL);
	layoutMain.setFill();
	layoutMain.setSpacing(0);
	
		// Title
		layoutTitle = new GuiLayout(Direction.VERTICAL);
		layoutTitle.setFillHorizontal();
		layoutTitle.setPaddingVertical(7);
		layoutTitle.setSpacing(1);
		
		_titleLabels = Arrays.stream(titleLines)
			.filter(Objects::nonNull).map(I18n::format)
			.map(GuiLabel::new).collect(Collectors.toList());
		_titleLabels.forEach(GuiLabel::setCenteredHorizontal);
		_titleLabels.forEach(layoutTitle::addFixed);
		
		// Content
		listEntries = new EntryList();
		scrollableContent = new EntryListScrollable(listEntries);
		
		// Buttons
		layoutButtons = new GuiLayout(Direction.HORIZONTAL);
		layoutButtons.setCenteredHorizontal();
		layoutButtons.setPaddingVertical(3, 9);
		layoutButtons.setSpacing(5);
		
			buttonDone  = new GuiButton(I18n.format("gui.done"));
			buttonUndo  = new GuiButtonGlyph(GuiUtils.UNDO_CHAR, I18n.format("fml.configgui.tooltip.undoChanges"));
			buttonReset = new GuiButtonGlyph(GuiUtils.RESET_CHAR, I18n.format("fml.configgui.tooltip.resetToDefault"));
			if (buttonDone.getWidth() < 100) buttonDone.setWidth(100);
			
			buttonDone.setAction(this::doneClicked);
			buttonUndo.setAction(this::undoChanges);
			buttonReset.setAction(this::setToDefault);
		
		layoutMain.addFixed(layoutTitle);
		layoutMain.addWeighted(scrollableContent);
		layoutMain.addFixed(layoutButtons);
	
	container.add(layoutMain);
}
 
Example #15
Source File: GuiSlider.java    From WearableBackpacks with MIT License 4 votes vote down vote up
/** Draws the slider background. */
protected void drawSliderBackground(boolean isHighlighted, float partialTicks) {
	GuiUtils.drawContinuousTexturedBox(GuiButton.BUTTON_TEX, 0, 0, 0, 46, getWidth(), getHeight(),
	                                   DEFAULT_WIDTH, DEFAULT_HEIGHT, 2, 3, 2, 2, 0);
}
 
Example #16
Source File: ComponentRenderer.java    From AgriCraft with MIT License 4 votes vote down vote up
public static void renderStackFrame(AgriGuiWrapper gui, GuiComponent<ItemStack> component) {
    GuiUtils.drawContinuousTexturedBox(WIDGETS, -1, -1, 142, 25, 18, 18, 18, 18, 2, 0);
}
 
Example #17
Source File: ComponentRenderer.java    From AgriCraft with MIT License 4 votes vote down vote up
public static void renderComponentButton(AgriGuiWrapper gui, GuiComponent<String> component) {
    GuiUtils.drawContinuousTexturedBox(WIDGETS, 0, 0, 0, 46 + getButtonNumber(component) * 20, component.getBounds().width, component.getBounds().height, 200, 20, 2, 3, 2, 2, 0);
    ComponentRenderer.renderComponentText(gui, component, getTextColor(component), true);
}
 
Example #18
Source File: Widget.java    From GregTech with GNU Lesser General Public License v3.0 4 votes vote down vote up
@SideOnly(Side.CLIENT)
protected static void drawGradientRect(int x, int y, int width, int height, int startColor, int endColor) {
    GuiUtils.drawGradientRect(0, x, y, x + width, y + height, startColor, endColor);
    GlStateManager.enableBlend();
}
 
Example #19
Source File: AdvancedTextWidget.java    From GregTech with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
protected void drawHoveringText(List<String> textLines, int x, int y, FontRenderer font) {
    GuiUtils.drawHoveringText(textLines, x, y, width, height, 256, font);
}