MalisisCore

48M Downloads

UIProgressBar alternation

JakiHappyCity opened this issue ยท 1 comments

commented

Hi, Ordinastie. I using your core for my mod. I want to create energy progress bar. I have this code:
`import net.malisis.core.client.gui.GuiRenderer;
import net.malisis.core.client.gui.MalisisGui;
import net.malisis.core.client.gui.component.UIComponent;
import net.malisis.core.client.gui.element.SimpleGuiShape;
import net.malisis.core.client.gui.icon.GuiIcon;
import net.malisis.core.renderer.icon.MalisisIcon;

public class UIHeatBar extends UIComponent {
protected GuiIcon barIcon;
protected GuiIcon barFilledIcon;
protected float progress = 0.0F;
protected boolean reversed = false;

public UIHeatBar(MalisisGui gui) {
    super(gui);
    this.setSize(14, 41);
    this.shape = new SimpleGuiShape();
    this.barIcon = new GuiIcon(new MalisisIcon("sb:textures/special/atlas.png", 1, 0, 14, 41));//gui.getGuiTexture().getIcon(246, 0, 22, 16);
    this.barFilledIcon = new GuiIcon(new MalisisIcon("sb:textures/special/atlas.png", 23, 36, 30, 41));//gui.getGuiTexture().getIcon(246, 16, 22, 16);
}

public float getProgress() {
    return this.progress;
}

public UIHeatBar setReversed() {
    this.reversed = true;
    return this;
}

public void setProgress(float progress) {
    if(progress < 0.0F) {
        progress = 0.0F;
    }

    if(progress > 1.0F) {
        progress = 1.0F;
    }

    this.progress = progress;
}

public void drawBackground(GuiRenderer renderer, int mouseX, int mouseY, float partialTick) {
    this.shape.resetState();
    this.shape.setSize((float)this.height, (float)this.height);
    this.barIcon.flip(this.reversed, false);
    this.rp.icon.set(this.barIcon);
    renderer.drawShape(this.shape, this.rp);
}

public void drawForeground(GuiRenderer renderer, int mouseX, int mouseY, float partialTick) {
    int height = (int)((float)this.height * this.progress);
    this.barFilledIcon.clip(0, 0, height, 17);
    this.barFilledIcon.flip(this.reversed, false);
    this.shape.resetState();
    this.shape.setSize((float)height, 41.0F);
    this.shape.translate(this.reversed?this.height - height:0, 0);
    this.rp.icon.set(this.barFilledIcon);
    renderer.drawShape(this.shape, this.rp);
}

}Have this "texture sprite": http://i.imgur.com/difveDj.png But texture not working and bar was rotate to right. This my gui for more info:import net.malisis.core.client.gui.Anchor;
import net.malisis.core.client.gui.MalisisGui;
import net.malisis.core.client.gui.component.container.UIPlayerInventory;
import net.malisis.core.client.gui.component.container.UIWindow;
import net.malisis.core.inventory.MalisisInventoryContainer;
import sb.common.tile.TileHeatGenerator;

public class GuiHeatGenerator extends MalisisGui {
private TileHeatGenerator te;
UIHeatBar heat;

public GuiHeatGenerator(MalisisInventoryContainer inventoryContainer, TileHeatGenerator tileEntity) {
    setInventoryContainer(inventoryContainer);
    this.te = tileEntity;
    guiscreenBackground = false;
}

@Override
public void construct() {
    UIWindow window = new UIWindow(this, 200, 150).setPosition(0, 0, Anchor.CENTER | Anchor.MIDDLE).setZIndex(0);

    /*
    UILabel plateCamoLabel = new UILabel(this, "Plate texture").setPosition(16, 5, Anchor.LEFT);
    UILabel buttonCamoLabel = new UILabel(this, "Switch texture").setPosition(-1, 5, Anchor.RIGHT);

    window.add(plateCamoLabel);
    window.add(buttonCamoLabel);
    */

    heat = new UIHeatBar(this).setPosition(0, 0, Anchor.CENTER | Anchor.MIDDLE);
    heat.setProgress(te.heat);

    UIPlayerInventory playerInv = new UIPlayerInventory(this, inventoryContainer.getPlayerInventory());

    window.add(heat);
    window.add(playerInv);

    addToScreen(window);
}

@Override
public void onGuiClosed() {
    super.onGuiClosed();
}

}`
Already thanks for support. And.... Sorry for my english, i very stupid in him, because i live in Russia and here i study english, but know not perfectly, sorry.

commented

Unfortunally i want to delete this thing.