use of betterquesting.api2.client.gui.misc.GuiTransform in project BetterQuesting by Funwayguy.
the class GuiQuestLines method initPanel.
@Override
public void initPanel() {
super.initPanel();
if (selectedLineId >= 0) {
selectedLine = QuestLineDatabase.INSTANCE.getValue(selectedLineId);
if (selectedLine == null) {
selectedLineId = -1;
}
} else {
selectedLine = null;
}
boolean canEdit = QuestingAPI.getAPI(ApiReference.SETTINGS).canUserEdit(mc.player);
PEventBroadcaster.INSTANCE.register(this, PEventButton.class);
CanvasTextured cvBackground = new CanvasTextured(new GuiTransform(GuiAlign.FULL_BOX, new GuiPadding(0, 0, 0, 0), 0), PresetTexture.PANEL_MAIN.getTexture());
this.addPanel(cvBackground);
if (canEdit) {
cvBackground.addPanel(new PanelButton(new GuiTransform(GuiAlign.BOTTOM_CENTER, -100, -16, 100, 16, 0), 0, I18n.format("gui.back")));
cvBackground.addPanel(new PanelButton(new GuiTransform(GuiAlign.BOTTOM_CENTER, 0, -16, 100, 16, 0), 3, I18n.format("betterquesting.btn.edit")));
} else {
cvBackground.addPanel(new PanelButton(new GuiTransform(GuiAlign.BOTTOM_CENTER, -100, -16, 200, 16, 0), 0, I18n.format("gui.back")));
}
CanvasScrolling cvList = new CanvasScrolling(new GuiTransform(GuiAlign.LEFT_EDGE, new GuiPadding(16, 16, -158, 16), 0));
cvBackground.addPanel(cvList);
PanelVScrollBar pnQScroll = new PanelVScrollBar(new GuiTransform(GuiAlign.RIGHT_EDGE, new GuiPadding(0, 0, -8, 0), 0));
cvList.setScrollDriverY(pnQScroll);
cvBackground.addPanel(pnQScroll);
pnQScroll.getTransform().setParent(cvList.getTransform());
List<IQuestLine> lineList = QuestLineDatabase.INSTANCE.getAllValues();
this.qlBtns = new PanelButtonStorage[lineList.size()];
UUID playerID = QuestingAPI.getQuestingUUID(mc.player);
for (int i = 0; i < lineList.size(); i++) {
IQuestLine ql = lineList.get(i);
PanelButtonStorage<IQuestLine> btnLine = new PanelButtonStorage<>(new GuiRectangle(0, i * 16, 142, 16, 0), 1, I18n.format(ql.getUnlocalisedName()), ql);
boolean show = canEdit;
if (!show) {
for (int qID : ql.getAllKeys()) {
IQuest q = QuestDatabase.INSTANCE.getValue(qID);
if (q != null && CanvasQuestLine.isQuestShown(q, playerID)) {
show = true;
break;
}
}
}
if (!show || ql == selectedLine) {
btnLine.setBtnState(false);
}
cvList.addPanel(btnLine);
qlBtns[i] = btnLine;
}
pnQScroll.setEnabled(cvList.getScrollBounds().getHeight() > 0);
CanvasTextured cvFrame = new CanvasTextured(new GuiTransform(GuiAlign.FULL_BOX, new GuiPadding(174, 16, 16, 66), 0), PresetTexture.AUX_FRAME_0.getTexture());
cvBackground.addPanel(cvFrame);
cvQuest = new CanvasQuestLine(new GuiTransform(GuiAlign.FULL_BOX, new GuiPadding(0, 0, 0, 0), 0), 2);
cvFrame.addPanel(cvQuest);
cvDesc = new CanvasScrolling(new GuiTransform(GuiAlign.BOTTOM_EDGE, new GuiPadding(174, -66, 24, 16), 0));
cvBackground.addPanel(cvDesc);
paDesc = new PanelTextBox(new GuiRectangle(0, 0, cvDesc.getTransform().getWidth(), 0, 0), "", true);
paDesc.setColor(PresetColor.TEXT_MAIN.getColor());
cvDesc.addPanel(paDesc);
scDesc = new PanelVScrollBar(new GuiTransform(GuiAlign.BOTTOM_RIGHT, new GuiPadding(-24, -66, 16, 16), 0));
cvDesc.setScrollDriverY(scDesc);
cvBackground.addPanel(scDesc);
if (selectedLine != null) {
cvQuest.setQuestLine(selectedLine);
cvQuest.setZoom(lastZoom);
cvQuest.setScrollX(lastScrollX);
cvQuest.setScrollY(lastScrollY);
paDesc.setText(I18n.format(selectedLine.getUnlocalisedDescription()));
scDesc.setEnabled(cvDesc.getScrollBounds().getHeight() > 0);
}
// === DECORATIVE LINES ===
IGuiRect ls0 = new GuiTransform(GuiAlign.TOP_LEFT, 16, 16, 0, 0, 0);
ls0.setParent(cvBackground.getTransform());
IGuiRect le0 = new GuiTransform(GuiAlign.TOP_LEFT, 166, 16, 0, 0, 0);
le0.setParent(cvBackground.getTransform());
PanelLine paLine0 = new PanelLine(ls0, le0, PresetLine.GUI_DIVIDER.getLine(), 1, PresetColor.GUI_DIVIDER.getColor(), -1);
cvBackground.addPanel(paLine0);
IGuiRect ls1 = new GuiTransform(GuiAlign.BOTTOM_LEFT, 16, -16, 0, 0, 0);
ls1.setParent(cvBackground.getTransform());
IGuiRect le1 = new GuiTransform(GuiAlign.BOTTOM_LEFT, 166, -16, 0, 0, 0);
le1.setParent(cvBackground.getTransform());
PanelLine paLine1 = new PanelLine(ls1, le1, PresetLine.GUI_DIVIDER.getLine(), 1, PresetColor.GUI_DIVIDER.getColor(), 1);
cvBackground.addPanel(paLine1);
IGuiRect ls3 = new GuiTransform(GuiAlign.BOTTOM_LEFT, 174, -16, 0, 0, 0);
ls3.setParent(cvBackground.getTransform());
IGuiRect le3 = new GuiTransform(GuiAlign.BOTTOM_RIGHT, -16, -16, 0, 0, 0);
le3.setParent(cvBackground.getTransform());
PanelLine paLine3 = new PanelLine(ls3, le3, PresetLine.GUI_DIVIDER.getLine(), 1, PresetColor.GUI_DIVIDER.getColor(), 1);
cvBackground.addPanel(paLine3);
}
Aggregations