use of betterquesting.api.questing.IQuest in project BetterQuesting by Funwayguy.
the class LegacyLoader_v0 method readQuestDatabase.
public void readQuestDatabase(JsonArray jAry) {
QuestDatabase.INSTANCE.reset();
for (JsonElement je : jAry) {
if (je == null || !je.isJsonObject()) {
continue;
}
JsonObject json = je.getAsJsonObject();
int qID = JsonHelper.GetNumber(json, "questID", -1).intValue();
IQuest quest = QuestDatabase.INSTANCE.getValue(qID);
boolean flag = quest == null;
quest = quest != null ? quest : new QuestInstance();
readQuest(quest, json);
if (quest != null && flag) {
QuestDatabase.INSTANCE.add(quest, qID);
}
}
}
use of betterquesting.api.questing.IQuest in project BetterQuesting by Funwayguy.
the class GuiQuestLines method onButtonPress.
private void onButtonPress(PEventButton event) {
Minecraft mc = Minecraft.getMinecraft();
IPanelButton btn = event.getButton();
if (// Exit
btn.getButtonID() == 0) {
mc.displayGuiScreen(this.parent);
} else if (// Quest Line Select
btn.getButtonID() == 1 && btn instanceof PanelButtonStorage) {
for (PanelButtonStorage b : qlBtns) {
if (b.getStoredValue() == selectedLine) {
b.setBtnState(true);
break;
}
}
@SuppressWarnings("unchecked") IQuestLine ql = ((PanelButtonStorage<IQuestLine>) btn).getStoredValue();
selectedLine = ql;
selectedLineId = QuestLineDatabase.INSTANCE.getKey(ql);
cvQuest.setQuestLine(ql);
paDesc.setText(I18n.format(ql.getUnlocalisedDescription()));
cvDesc.refreshScrollBounds();
scDesc.setEnabled(cvDesc.getScrollBounds().getHeight() > 0);
btn.setBtnState(false);
} else if (// Quest Instance Select
btn.getButtonID() == 2 && btn instanceof PanelButtonStorage) {
@SuppressWarnings("unchecked") IQuest quest = ((PanelButtonStorage<IQuest>) btn).getStoredValue();
GuiHome.bookmark = new GuiQuest(this, QuestDatabase.INSTANCE.getKey(quest));
this.lastScrollX = cvQuest.getScrollX();
this.lastScrollY = cvQuest.getScrollY();
this.lastZoom = cvQuest.getZoom();
mc.displayGuiScreen(GuiHome.bookmark);
} else if (btn.getButtonID() == 3) {
mc.displayGuiScreen(new GuiQuestLineEditorA(this));
}
}
use of betterquesting.api.questing.IQuest in project BetterQuesting by Funwayguy.
the class ImportedQuests method writeToNBT.
@Override
public NBTTagList writeToNBT(NBTTagList json, EnumSaveType saveType) {
if (saveType != EnumSaveType.CONFIG) {
return json;
}
for (Entry<Integer, IQuest> entry : database.entrySet()) {
NBTTagCompound jq = new NBTTagCompound();
entry.getValue().writeToNBT(jq, saveType);
jq.setInteger("questID", entry.getKey());
json.appendTag(jq);
}
return json;
}
use of betterquesting.api.questing.IQuest in project BetterQuesting by Funwayguy.
the class GuiQuestLinesEmbedded method drawBackground.
@Override
public void drawBackground(int mx, int my, float partialTick) {
mouseDrag(mx, my);
Minecraft mc = Minecraft.getMinecraft();
double scaleX = sizeX / 128D;
double scaleY = sizeY / 128D;
float zs = zoom / 100F;
int rmx = getRelativeX(mx);
int rmy = getRelativeY(my);
mc.renderEngine.bindTexture(currentTheme().getGuiTexture());
GlStateManager.color(1F, 1F, 1F, 1F);
GlStateManager.pushMatrix();
GlStateManager.scale(scaleX, scaleY, 1F);
GlStateManager.translate(posX / scaleX, posY / scaleY, 0);
drawTexturedModalRect(0, 0, 0, 128, 128, 128);
GlStateManager.popMatrix();
IQuest qTooltip = null;
if (qLine != null) {
GlStateManager.pushMatrix();
RenderUtils.startScissor(mc, new GuiRectangle(posX, posY, sizeX, sizeY));
GlStateManager.translate(posX + (scrollX) * zs, posY + (scrollY) * zs, 0);
GlStateManager.scale(zs, zs, 1F);
if (bgImg != null) {
GlStateManager.pushMatrix();
GlStateManager.scale(bgSize / 256F, bgSize / 256F, 1F);
mc.renderEngine.bindTexture(bgImg);
this.drawTexturedModalRect(0, 0, 0, 0, 256, 256);
GlStateManager.popMatrix();
}
for (int i = 0; i < qBtns.size(); i++) {
GuiButtonQuestInstance btnQuest = qBtns.get(i);
btnQuest.drawButton(mc, rmx, rmy, partialTick);
if (btnQuest.visible && isWithin(rmx, rmy, btnQuest.x, btnQuest.y, btnQuest.width, btnQuest.height) && isWithin(mx, my, posX, posY, sizeX, sizeY)) {
qTooltip = btnQuest.getQuest();
}
}
RenderUtils.endScissor(mc);
GlStateManager.popMatrix();
}
if (curTool != null) {
GlStateManager.pushMatrix();
RenderUtils.startScissor(mc, new GuiRectangle(posX, posY, sizeX, sizeY));
GlStateManager.translate(posX + (scrollX) * zs, posY + (scrollY) * zs, 0);
GlStateManager.scale(zs, zs, 1F);
curTool.drawTool(rmx, rmy, partialTick);
RenderUtils.endScissor(mc);
GlStateManager.popMatrix();
}
if (qTooltip != null && (curTool == null || curTool.allowTooltips())) {
curTooltip = qTooltip.getTooltip(mc.player);
} else {
curTooltip = null;
}
}
use of betterquesting.api.questing.IQuest in project BetterQuesting by Funwayguy.
the class GuiPrerequisiteEditor method RefreshColumns.
public void RefreshColumns() {
prBtnList.getEntryList().clear();
for (IQuest prq : quest.getPrerequisites()) {
int qID = QuestDatabase.INSTANCE.getKey(prq);
int btnWidth = prBtnList.getListWidth();
// First 3 bits reserved for column index
int bID = (2 + qID) << 3;
GuiButtonThemed btn1 = new GuiButtonThemed(bID + 0, 0, 0, btnWidth - 20, 20, I18n.format(prq.getUnlocalisedName()));
GuiButtonThemed btn2 = new GuiButtonThemed(bID + 1, 0, 0, 20, 20, TextFormatting.YELLOW + ">");
prBtnList.addButtonRow(btn1, btn2);
}
dbBtnList.getEntryList().clear();
for (int qID : searchResults) {
IQuest dbQ = QuestDatabase.INSTANCE.getValue(qID);
if (dbQ == null) {
continue;
}
int bWidth = dbBtnList.getListWidth();
// First 3 bits reserved for column index
int bID = (2 + qID) << 3;
GuiButtonThemed btn3 = new GuiButtonThemed(bID + 2, 0, 0, 20, 20, TextFormatting.GREEN + "<");
btn3.enabled = dbQ != null && quest != dbQ && !quest.getPrerequisites().contains(dbQ);
GuiButtonThemed btn4 = new GuiButtonThemed(bID + 3, 0, 0, bWidth - 40, 20, I18n.format(dbQ.getUnlocalisedName()));
GuiButtonThemed btn5 = new GuiButtonThemed(bID + 4, 0, 0, 20, 20, "" + TextFormatting.BOLD + TextFormatting.RED + "x");
dbBtnList.addButtonRow(btn3, btn4, btn5);
}
}
Aggregations