Search in sources :

Example 1 with EnumQuestState

use of betterquesting.api.enums.EnumQuestState in project BetterQuesting by Funwayguy.

the class ThemeRenderStandard method drawLine.

@Override
public void drawLine(IQuest quest, UUID playerID, float x1, float y1, float x2, float y2, int mx, int my, float partialTick) {
    boolean isMain = quest == null ? false : quest.getProperties().getProperty(NativeProps.MAIN);
    EnumQuestState qState = quest == null || playerID == null ? EnumQuestState.LOCKED : quest.getState(playerID);
    GlStateManager.pushMatrix();
    GlStateManager.disableTexture2D();
    int cl = getQuestLineColor(qState);
    float lr = (float) (cl >> 16 & 255) / 255.0F;
    float lg = (float) (cl >> 8 & 255) / 255.0F;
    float lb = (float) (cl & 255) / 255.0F;
    GlStateManager.color(lr, lg, lb, 1F);
    GL11.glLineWidth(isMain ? 8F : 4F);
    GL11.glEnable(GL11.GL_LINE_STIPPLE);
    GL11.glLineStipple(8, (short) 0xFFFF);
    GL11.glBegin(GL11.GL_LINES);
    GL11.glVertex2f(x1, y1);
    GL11.glVertex2f(x2, y2);
    GL11.glEnd();
    GL11.glLineStipple(1, Short.MAX_VALUE);
    GL11.glDisable(GL11.GL_LINE_STIPPLE);
    GlStateManager.enableTexture2D();
    GlStateManager.color(1F, 1F, 1F, 1F);
    GlStateManager.popMatrix();
}
Also used : EnumQuestState(betterquesting.api.enums.EnumQuestState)

Example 2 with EnumQuestState

use of betterquesting.api.enums.EnumQuestState in project BetterQuesting by Funwayguy.

the class CanvasQuestLine method setQuestLine.

/**
 * Loads in quests and connecting lines
 * @param line The quest line to load
 */
public void setQuestLine(IQuestLine line) {
    // Rest contents
    this.getAllPanels().clear();
    if (line == null) {
        return;
    }
    EntityPlayer player = Minecraft.getMinecraft().player;
    UUID pid = QuestingAPI.getQuestingUUID(player);
    String bgString = line.getProperties().getProperty(NativeProps.BG_IMAGE);
    if (bgString != null && bgString.length() > 0) {
        ResourceLocation bgRes = new ResourceLocation(bgString);
        int bgSize = line.getProperties().getProperty(NativeProps.BG_SIZE);
        this.addPanel(new PanelGeneric(new GuiRectangle(0, 0, bgSize, bgSize), new SimpleTexture(bgRes, new GuiRectangle(0, 0, 256, 256))));
    }
    // Used later to center focus the quest line within the window
    boolean flag = false;
    int minX = 0;
    int minY = 0;
    int maxX = 0;
    int maxY = 0;
    HashMap<Integer, PanelButtonStorage<IQuest>> questBtns = new HashMap<>();
    for (IQuestLineEntry qle : line.getAllValues()) {
        int id = line.getKey(qle);
        IQuest quest = QuestDatabase.INSTANCE.getValue(id);
        if (quest == null || !isQuestShown(quest, pid)) {
            continue;
        }
        EnumQuestState qState = quest.getState(pid);
        IGuiTexture txFrame = null;
        IGuiColor txIconCol = null;
        boolean main = quest.getProperties().getProperty(NativeProps.MAIN);
        switch(qState) {
            case LOCKED:
                txFrame = main ? PresetTexture.QUEST_MAIN_0.getTexture() : PresetTexture.QUEST_NORM_0.getTexture();
                txIconCol = PresetColor.QUEST_ICON_LOCKED.getColor();
                break;
            case UNLOCKED:
                txFrame = main ? PresetTexture.QUEST_MAIN_1.getTexture() : PresetTexture.QUEST_NORM_1.getTexture();
                txIconCol = PresetColor.QUEST_ICON_UNLOCKED.getColor();
                break;
            case UNCLAIMED:
                txFrame = main ? PresetTexture.QUEST_MAIN_2.getTexture() : PresetTexture.QUEST_NORM_2.getTexture();
                txIconCol = PresetColor.QUEST_ICON_PENDING.getColor();
                break;
            case COMPLETED:
                txFrame = main ? PresetTexture.QUEST_MAIN_3.getTexture() : PresetTexture.QUEST_NORM_3.getTexture();
                txIconCol = PresetColor.QUEST_ICON_COMPLETE.getColor();
                break;
        }
        IGuiRect rect = new GuiRectangle(qle.getPosX(), qle.getPosY(), qle.getSize(), qle.getSize());
        PanelButtonStorage<IQuest> paBtn = new PanelButtonStorage<>(rect, buttonId, "", quest);
        paBtn.setTextures(new GuiTextureColored(txFrame, txIconCol), new GuiTextureColored(txFrame, txIconCol), new GuiTextureColored(txFrame, txIconCol));
        paBtn.setIcon(new ItemTexture(quest.getItemIcon()), 4);
        paBtn.setTooltip(quest.getTooltip(player));
        this.addPanel(paBtn);
        questBtns.put(id, paBtn);
        if (!flag) {
            minX = rect.getX();
            minY = rect.getY();
            maxX = minX + rect.getWidth();
            maxY = minY + rect.getHeight();
            flag = true;
        } else {
            minX = Math.min(minX, rect.getX());
            minY = Math.min(minY, rect.getY());
            maxX = Math.max(maxX, rect.getX() + rect.getWidth());
            maxY = Math.max(maxY, rect.getY() + rect.getHeight());
        }
    }
    for (Entry<Integer, PanelButtonStorage<IQuest>> entry : questBtns.entrySet()) {
        IQuest quest = entry.getValue().getStoredValue();
        List<IQuest> reqList = quest.getPrerequisites();
        if (reqList.size() <= 0) {
            continue;
        }
        boolean main = quest.getProperties().getProperty(NativeProps.MAIN);
        EnumQuestState qState = quest.getState(pid);
        IGuiLine lineRender = null;
        IGuiColor txLineCol = null;
        switch(qState) {
            case LOCKED:
                lineRender = PresetLine.QUEST_LOCKED.getLine();
                txLineCol = PresetColor.QUEST_LINE_LOCKED.getColor();
                break;
            case UNLOCKED:
                lineRender = PresetLine.QUEST_UNLOCKED.getLine();
                txLineCol = PresetColor.QUEST_LINE_UNLOCKED.getColor();
                break;
            case UNCLAIMED:
                lineRender = PresetLine.QUEST_PENDING.getLine();
                txLineCol = PresetColor.QUEST_LINE_PENDING.getColor();
                break;
            case COMPLETED:
                lineRender = PresetLine.QUEST_COMPLETE.getLine();
                txLineCol = PresetColor.QUEST_LINE_COMPLETE.getColor();
                break;
        }
        for (IQuest req : reqList) {
            int id = QuestDatabase.INSTANCE.getKey(req);
            PanelButtonStorage<IQuest> parBtn = questBtns.get(id);
            if (parBtn != null) {
                PanelLine prLine = new PanelLine(parBtn.getTransform(), entry.getValue().getTransform(), lineRender, main ? 8 : 4, txLineCol, 1);
                this.addPanel(prLine);
            }
        }
    }
    float frameW = getTransform().getWidth();
    float frameH = getTransform().getHeight();
    if (frameW <= 0 || frameH <= 0) {
        return;
    }
    minX -= margin;
    minY -= margin;
    maxX += margin;
    maxY += margin;
    float scale = Math.min(frameW / (maxX - minX), frameH / (maxY - minY));
    scale = MathHelper.clamp(scale, 0.25F, 2F);
    this.setZoom(scale);
    int scrollX = Math.round((maxX - minX) / 2F - (frameW / scale) / 2F);
    int scrollY = Math.round((maxY - minY) / 2F - (frameH / scale) / 2F);
    this.setScrollX(scrollX);
    this.setScrollY(scrollY);
}
Also used : HashMap(java.util.HashMap) IGuiColor(betterquesting.api2.client.gui.resources.colors.IGuiColor) IGuiRect(betterquesting.api2.client.gui.misc.IGuiRect) ResourceLocation(net.minecraft.util.ResourceLocation) UUID(java.util.UUID) PanelButtonStorage(betterquesting.api2.client.gui.controls.PanelButtonStorage) IQuest(betterquesting.api.questing.IQuest) IGuiTexture(betterquesting.api2.client.gui.resources.textures.IGuiTexture) GuiRectangle(betterquesting.api2.client.gui.misc.GuiRectangle) IGuiLine(betterquesting.api2.client.gui.resources.lines.IGuiLine) IQuestLineEntry(betterquesting.api.questing.IQuestLineEntry) PanelLine(betterquesting.api2.client.gui.panels.content.PanelLine) SimpleTexture(betterquesting.api2.client.gui.resources.textures.SimpleTexture) GuiTextureColored(betterquesting.api2.client.gui.resources.textures.GuiTextureColored) EnumQuestState(betterquesting.api.enums.EnumQuestState) EntityPlayer(net.minecraft.entity.player.EntityPlayer) PanelGeneric(betterquesting.api2.client.gui.panels.content.PanelGeneric) ItemTexture(betterquesting.api2.client.gui.resources.textures.ItemTexture)

Example 3 with EnumQuestState

use of betterquesting.api.enums.EnumQuestState in project BetterQuesting by Funwayguy.

the class ThemeRenderStandard method drawIcon.

@Override
public void drawIcon(IQuest quest, UUID playerID, float px, float py, float sx, float sy, int mx, int my, float partialTick) {
    boolean isMain = quest == null ? false : quest.getProperties().getProperty(NativeProps.MAIN);
    EnumQuestState qState = quest == null || playerID == null ? EnumQuestState.LOCKED : quest.getState(playerID);
    boolean hover = mx >= px && my >= py && mx < px + sx && my < py + sy;
    GlStateManager.pushMatrix();
    int ci = getQuestIconColor(qState, qState == EnumQuestState.LOCKED ? 0 : (!hover ? 1 : 2));
    float ir = (float) (ci >> 16 & 255) / 255.0F;
    float ig = (float) (ci >> 8 & 255) / 255.0F;
    float ib = (float) (ci & 255) / 255.0F;
    GlStateManager.color(ir, ig, ib, 1F);
    GlStateManager.translate(px, py, 0F);
    float sw = sx / 24;
    float sh = sy / 24;
    GlStateManager.scale(sw, sh, 1F);
    Minecraft.getMinecraft().renderEngine.bindTexture(currentTheme().getGuiTexture());
    this.drawTexturedModalRect(0, 0, (isMain ? 24 : 0), 104, 24, 24);
    if (quest == null) {
        RenderUtils.RenderItemStack(Minecraft.getMinecraft(), new ItemStack(Items.NETHER_STAR), 4, 4, "");
    } else if (quest.getItemIcon() != null) {
        RenderUtils.RenderItemStack(Minecraft.getMinecraft(), quest.getItemIcon().getBaseStack(), 4, 4, "");
    }
    GlStateManager.popMatrix();
}
Also used : EnumQuestState(betterquesting.api.enums.EnumQuestState) ItemStack(net.minecraft.item.ItemStack)

Aggregations

EnumQuestState (betterquesting.api.enums.EnumQuestState)3 IQuest (betterquesting.api.questing.IQuest)1 IQuestLineEntry (betterquesting.api.questing.IQuestLineEntry)1 PanelButtonStorage (betterquesting.api2.client.gui.controls.PanelButtonStorage)1 GuiRectangle (betterquesting.api2.client.gui.misc.GuiRectangle)1 IGuiRect (betterquesting.api2.client.gui.misc.IGuiRect)1 PanelGeneric (betterquesting.api2.client.gui.panels.content.PanelGeneric)1 PanelLine (betterquesting.api2.client.gui.panels.content.PanelLine)1 IGuiColor (betterquesting.api2.client.gui.resources.colors.IGuiColor)1 IGuiLine (betterquesting.api2.client.gui.resources.lines.IGuiLine)1 GuiTextureColored (betterquesting.api2.client.gui.resources.textures.GuiTextureColored)1 IGuiTexture (betterquesting.api2.client.gui.resources.textures.IGuiTexture)1 ItemTexture (betterquesting.api2.client.gui.resources.textures.ItemTexture)1 SimpleTexture (betterquesting.api2.client.gui.resources.textures.SimpleTexture)1 HashMap (java.util.HashMap)1 UUID (java.util.UUID)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 ItemStack (net.minecraft.item.ItemStack)1 ResourceLocation (net.minecraft.util.ResourceLocation)1