use of betterquesting.api2.client.gui.resources.textures.IGuiTexture in project BetterQuesting by Funwayguy.
the class GuiHome method initPanel.
@Override
public void initPanel() {
super.initPanel();
PEventBroadcaster.INSTANCE.register(this, PEventButton.class);
ResourceLocation homeGui = new ResourceLocation(QuestSettings.INSTANCE.getProperty(NativeProps.HOME_IMAGE));
IGuiTexture homeSplashBG = new SimpleTexture(homeGui, new GuiRectangle(0, 0, 256, 128));
IGuiTexture homeSplashTitle = new SimpleTexture(homeGui, new GuiRectangle(0, 128, 256, 128)).maintainAspect(true);
float ancX = QuestSettings.INSTANCE.getProperty(NativeProps.HOME_ANC_X);
float ancY = QuestSettings.INSTANCE.getProperty(NativeProps.HOME_ANC_Y);
int offX = QuestSettings.INSTANCE.getProperty(NativeProps.HOME_OFF_X);
int offY = QuestSettings.INSTANCE.getProperty(NativeProps.HOME_OFF_Y);
// Background panel
CanvasTextured bgCan = new CanvasTextured(new GuiTransform(GuiAlign.FULL_BOX, new GuiPadding(0, 0, 0, 0), 0), PresetTexture.PANEL_MAIN.getTexture());
this.addPanel(bgCan);
// Inner canvas bounds
CanvasEmpty inCan = new CanvasEmpty(new GuiTransform(GuiAlign.FULL_BOX, new GuiPadding(16, 16, 16, 16), 0));
bgCan.addPanel(inCan);
CanvasTextured splashCan = new CanvasTextured(new GuiTransform(GuiAlign.FULL_BOX, new GuiPadding(0, 0, 0, 32), 0), homeSplashBG);
inCan.addPanel(splashCan);
CanvasTextured splashTitle = new CanvasTextured(new GuiTransform(new Vector4f(ancX, ancY, ancX, ancY), new GuiPadding(offX, offY, -256 - offX, -128 - offY), 0), homeSplashTitle);
splashCan.addPanel(splashTitle);
PanelButton btnExit = new PanelButton(new GuiTransform(new Vector4f(0F, 1F, 0.25F, 1F), new GuiPadding(0, -32, 0, 0), 0), 0, I18n.format("betterquesting.home.exit"));
inCan.addPanel(btnExit);
PanelButton btnQuests = new PanelButton(new GuiTransform(new Vector4f(0.25F, 1F, 0.5F, 1F), new GuiPadding(0, -32, 0, 0), 0), 1, I18n.format("betterquesting.home.quests"));
inCan.addPanel(btnQuests);
PanelButton btnParty = new PanelButton(new GuiTransform(new Vector4f(0.5F, 1F, 0.75F, 1F), new GuiPadding(0, -32, 0, 0), 0), 2, I18n.format("betterquesting.home.party"));
inCan.addPanel(btnParty);
PanelButton btnTheme = new PanelButton(new GuiTransform(new Vector4f(0.75F, 1F, 1F, 1F), new GuiPadding(0, -32, 0, 0), 0), 3, I18n.format("betterquesting.home.theme"));
inCan.addPanel(btnTheme);
if (QuestingAPI.getAPI(ApiReference.SETTINGS).canUserEdit(mc.player)) {
PanelButton btnEdit = new PanelButton(new GuiTransform(GuiAlign.TOP_LEFT, new GuiPadding(0, 0, -16, -16), 0), 4, "").setIcon(PresetIcon.ICON_GEAR.getTexture());
inCan.addPanel(btnEdit);
}
}
use of betterquesting.api2.client.gui.resources.textures.IGuiTexture in project BetterQuesting by Funwayguy.
the class GuiThemes method initPanel.
@Override
public void initPanel() {
super.initPanel();
PEventBroadcaster.INSTANCE.register(this, PEventButton.class);
// Background panel
CanvasTextured bgCan = new CanvasTextured(new GuiTransform(GuiAlign.FULL_BOX, new GuiPadding(0, 0, 0, 0), 0), PresetTexture.PANEL_MAIN.getTexture());
this.addPanel(bgCan);
// Inner canvas bounds
CanvasEmpty inCan = new CanvasEmpty(new GuiTransform(GuiAlign.FULL_BOX, new GuiPadding(16, 16, 16, 16), 0));
bgCan.addPanel(inCan);
PanelTextBox panTxt = new PanelTextBox(new GuiTransform(GuiAlign.TOP_EDGE, new GuiPadding(0, 0, 0, -16), 0), I18n.format("betterquesting.title.select_theme")).setAlignment(1);
panTxt.setColor(PresetColor.TEXT_HEADER.getColor());
inCan.addPanel(panTxt);
PanelButton btnExit = new PanelButton(new GuiTransform(GuiAlign.BOTTOM_CENTER, new GuiPadding(-100, -16, -100, 0), 0), 0, I18n.format("gui.done"));
bgCan.addPanel(btnExit);
CanvasScrolling canScroll = new CanvasScrolling(new GuiTransform(GuiAlign.HALF_LEFT, new GuiPadding(0, 16, 16, 16), 0));
inCan.addPanel(canScroll);
List<ITheme> themes = betterquesting.client.themes.ThemeRegistry.INSTANCE.getAllThemes();
// List<IGuiTheme> themes = ThemeRegistry.INSTANCE.getAllThemes();
int width = canScroll.getTransform().getWidth();
for (int i = 0; i < themes.size(); i++) {
GuiRectangle trans = new GuiRectangle(0, i * 24, width, 24, 0);
ITheme theme = themes.get(i);
PanelButtonStorage<ResourceLocation> pbs = new PanelButtonStorage<>(trans, 1, theme.getDisplayName(), theme.getThemeID());
canScroll.addPanel(pbs);
if (betterquesting.client.themes.ThemeRegistry.INSTANCE.getCurrentTheme() == theme) {
pbs.setEnabled(false);
}
}
PanelVScrollBar vsb = new PanelVScrollBar(new GuiTransform(GuiAlign.RIGHT_EDGE, new GuiPadding(0, 0, -8, 0), 0));
inCan.addPanel(vsb);
vsb.getTransform().setParent(canScroll.getTransform());
canScroll.setScrollDriverY(vsb);
scrollPanel = vsb;
// === PREVIEW PANELS ===
CanvasEmpty preCan = new CanvasEmpty(new GuiTransform(GuiAlign.HALF_RIGHT, new GuiPadding(8, 16, 0, 16), 0));
inCan.addPanel(preCan);
CanvasTextured preCanIn0 = new CanvasTextured(new GuiTransform(new Vector4f(0F, 0F, 0.5F, 0.5F), new GuiPadding(0, 0, 0, 0), 0), PresetTexture.PANEL_MAIN.getTexture());
preCan.addPanel(preCanIn0);
preCanIn0.addPanel(new PanelTextBox(new GuiTransform(GuiAlign.MID_CENTER, -32, -8, 64, 16, 0), "EXAMPLE").setAlignment(1).setColor(PresetColor.TEXT_MAIN.getColor()));
CanvasTextured preCanIn1 = new CanvasTextured(new GuiTransform(new Vector4f(0.5F, 0F, 1F, 0.5F), new GuiPadding(0, 0, 0, 0), 0), PresetTexture.PANEL_INNER.getTexture());
preCanIn1.addPanel(new PanelTextBox(new GuiTransform(GuiAlign.MID_CENTER, -32, -8, 64, 16, 0), "EXAMPLE").setAlignment(1).setColor(PresetColor.TEXT_AUX_0.getColor()));
preCan.addPanel(preCanIn1);
CanvasTextured preCanIn2 = new CanvasTextured(new GuiTransform(GuiAlign.HALF_BOTTOM, new GuiPadding(0, 0, 0, 0), 0), PresetTexture.AUX_FRAME_0.getTexture());
preCan.addPanel(preCanIn2);
IGuiTexture icoSlides = new SlideShowTexture(1F, new GuiTextureColored(PresetTexture.QUEST_NORM_0.getTexture(), PresetColor.QUEST_ICON_LOCKED.getColor()), new GuiTextureColored(PresetTexture.QUEST_NORM_1.getTexture(), PresetColor.QUEST_ICON_UNLOCKED.getColor()), new GuiTextureColored(PresetTexture.QUEST_NORM_2.getTexture(), PresetColor.QUEST_ICON_PENDING.getColor()), new GuiTextureColored(PresetTexture.QUEST_NORM_3.getTexture(), PresetColor.QUEST_ICON_COMPLETE.getColor()), new GuiTextureColored(PresetTexture.QUEST_MAIN_0.getTexture(), PresetColor.QUEST_ICON_LOCKED.getColor()), new GuiTextureColored(PresetTexture.QUEST_MAIN_1.getTexture(), PresetColor.QUEST_ICON_UNLOCKED.getColor()), new GuiTextureColored(PresetTexture.QUEST_MAIN_2.getTexture(), PresetColor.QUEST_ICON_PENDING.getColor()), new GuiTextureColored(PresetTexture.QUEST_MAIN_3.getTexture(), PresetColor.QUEST_ICON_COMPLETE.getColor()), new GuiTextureColored(PresetTexture.QUEST_AUX_0.getTexture(), PresetColor.QUEST_ICON_LOCKED.getColor()), new GuiTextureColored(PresetTexture.QUEST_AUX_1.getTexture(), PresetColor.QUEST_ICON_UNLOCKED.getColor()), new GuiTextureColored(PresetTexture.QUEST_AUX_2.getTexture(), PresetColor.QUEST_ICON_PENDING.getColor()), new GuiTextureColored(PresetTexture.QUEST_AUX_3.getTexture(), PresetColor.QUEST_ICON_COMPLETE.getColor()));
PanelGeneric pqp = new PanelGeneric(new GuiTransform(new Vector4f(0.25F, 0.5F, 0.25F, 0.5F), -12, -12, 24, 24, 0), icoSlides);
preCanIn2.addPanel(pqp);
CanvasTextured itemFrame = new CanvasTextured(new GuiTransform(new Vector4f(0.75F, 0.5F, 0.75F, 0.5F), -12, -12, 24, 24, 0), PresetTexture.ITEM_FRAME.getTexture());
itemFrame.addPanel(new PanelGeneric(new GuiTransform(GuiAlign.FULL_BOX, new GuiPadding(1, 1, 1, 1), 0), new ItemTexture(new BigItemStack(BetterQuesting.guideBook))));
preCanIn2.addPanel(itemFrame);
IGuiLine linSeq = new GuiLineSequence(1F, PresetLine.QUEST_LOCKED.getLine(), PresetLine.QUEST_UNLOCKED.getLine(), PresetLine.QUEST_PENDING.getLine(), PresetLine.QUEST_COMPLETE.getLine());
IGuiColor colSeq = new GuiColorSequence(1F, PresetColor.QUEST_LINE_LOCKED.getColor(), PresetColor.QUEST_LINE_UNLOCKED.getColor(), PresetColor.QUEST_LINE_PENDING.getColor(), PresetColor.QUEST_LINE_COMPLETE.getColor());
preCanIn2.addPanel(new PanelLine(pqp.getTransform(), itemFrame.getTransform(), linSeq, 4, colSeq, 1));
preCanIn2.addPanel(new PanelTextBox(new GuiTransform(GuiAlign.FULL_BOX, new GuiPadding(8, 8, 8, 8), 0), "EXAMPLE").setAlignment(1).setColor(PresetColor.TEXT_AUX_1.getColor()));
IGuiRect ls0 = new GuiTransform(GuiAlign.TOP_CENTER, 0, 16, 0, 0, 0);
ls0.setParent(inCan.getTransform());
IGuiRect le0 = new GuiTransform(GuiAlign.BOTTOM_CENTER, 0, -16, 0, 0, 0);
le0.setParent(inCan.getTransform());
PanelLine paLine0 = new PanelLine(ls0, le0, PresetLine.GUI_DIVIDER.getLine(), 1, PresetColor.GUI_DIVIDER.getColor(), 1);
inCan.addPanel(paLine0);
}
use of betterquesting.api2.client.gui.resources.textures.IGuiTexture 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);
}
use of betterquesting.api2.client.gui.resources.textures.IGuiTexture in project BetterQuesting by Funwayguy.
the class PanelButton method drawPanel.
@Override
public void drawPanel(int mx, int my, float partialTick) {
IGuiRect bounds = this.getTransform();
GlStateManager.pushMatrix();
GlStateManager.color(1F, 1F, 1F, 1F);
int curState = !getBtnState() ? 0 : (bounds.contains(mx, my) ? 2 : 1);
if (curState == 2 && pendingRelease && Mouse.isButtonDown(0)) {
curState = 0;
}
IGuiTexture t = texStates[curState];
if (// Support for text or icon only buttons in one or more states.
t != null) {
t.drawTexture(bounds.getX(), bounds.getY(), bounds.getWidth(), bounds.getHeight(), 0F, partialTick);
}
if (texIcon != null) {
int isz = Math.min(bounds.getHeight() - icoPadding, bounds.getWidth() - icoPadding);
if (isz > 0) {
texIcon.drawTexture(bounds.getX() + (bounds.getWidth() / 2) - (isz / 2), bounds.getY() + (bounds.getHeight() / 2) - (isz / 2), isz, isz, 0F, partialTick);
}
}
if (btnText != null && btnText.length() > 0) {
drawCenteredString(Minecraft.getMinecraft().fontRenderer, btnText, bounds.getX() + bounds.getWidth() / 2, bounds.getY() + bounds.getHeight() / 2 - 4, colStates[curState].getRGB(), txtShadow);
}
GlStateManager.popMatrix();
}
use of betterquesting.api2.client.gui.resources.textures.IGuiTexture in project BetterQuesting by Funwayguy.
the class ThemeRegistry method getTexture.
public IGuiTexture getTexture(ResourceLocation key) {
if (key == null) {
return NULL_TEXTURE;
}
IGuiTexture tex = null;
// TODO: Remove this when fully converted...
ITheme legTheme = betterquesting.client.themes.ThemeRegistry.INSTANCE.getCurrentTheme();
if (legTheme != null && (activeTheme == null || !activeTheme.getID().equals(legTheme.getThemeID()))) {
activeTheme = new LegacyThemeWrapper(legTheme);
}
if (activeTheme != null) {
tex = activeTheme.getTexture(key);
}
tex = tex != null ? tex : defTextures.get(key);
return tex == null ? NULL_TEXTURE : tex;
}
Aggregations