use of betterquesting.api.questing.IQuestLine 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.IQuestLine in project BetterQuesting by Funwayguy.
the class ImportedQuestLines method createNew.
@Override
public IQuestLine createNew() {
QuestLine ql = new QuestLine();
ql.setParentDatabase(this);
return ql;
}
use of betterquesting.api.questing.IQuestLine in project BetterQuesting by Funwayguy.
the class ImportedQuestLines method writeToNBT.
@Override
public NBTTagList writeToNBT(NBTTagList json, EnumSaveType saveType) {
if (saveType != EnumSaveType.CONFIG) {
return json;
}
for (Entry<Integer, IQuestLine> entry : questLines.entrySet()) {
if (entry.getValue() == null) {
continue;
}
int id = entry.getKey();
NBTTagCompound jObj = entry.getValue().writeToNBT(new NBTTagCompound(), saveType);
jObj.setInteger("lineID", id);
jObj.setInteger("order", getOrderIndex(id));
json.appendTag(jObj);
}
return json;
}
use of betterquesting.api.questing.IQuestLine in project BetterQuesting by Funwayguy.
the class GuiQuestLineEditorA method SendChanges.
public void SendChanges(EnumPacketAction action, int lineID, int order) {
IQuestLine questLine = QuestLineDatabase.INSTANCE.getValue(lineID);
if (action == null) {
return;
}
NBTTagCompound tags = new NBTTagCompound();
if (action == EnumPacketAction.EDIT && questLine != null) {
NBTTagCompound base = new NBTTagCompound();
base.setTag("line", questLine.writeToNBT(new NBTTagCompound(), EnumSaveType.CONFIG));
tags.setTag("data", base);
}
tags.setInteger("lineID", questLine == null ? -1 : QuestLineDatabase.INSTANCE.getKey(questLine));
tags.setInteger("order", order);
tags.setInteger("action", action.ordinal());
PacketSender.INSTANCE.sendToServer(new QuestingPacket(PacketTypeNative.LINE_EDIT.GetLocation(), tags));
}
use of betterquesting.api.questing.IQuestLine in project BetterQuesting by Funwayguy.
the class ToolboxToolCopy method onMouseClick.
@Override
public void onMouseClick(int mx, int my, int click) {
if (click == 1 && btnQuest != null) {
btnQuest = null;
} else if (click != 0) {
return;
}
int snap = ToolboxGuiMain.getSnapValue();
int modX = ((mx % snap) + snap) % snap;
int modY = ((my % snap) + snap) % snap;
mx -= modX;
my -= modY;
if (btnQuest == null) {
GuiButtonQuestInstance tmpBtn = gui.getQuestLine().getButtonAt(mx, my);
if (tmpBtn != null) {
// Unregistered but setup
QuestInstance tmpQ = new QuestInstance();
tmpQ.readFromNBT(tmpBtn.getQuest().writeToNBT(new NBTTagCompound(), EnumSaveType.CONFIG), EnumSaveType.CONFIG);
btnQuest = new GuiButtonQuestInstance(0, mx, my, tmpBtn.width, tmpBtn.height, tmpQ);
}
} else {
// Pre-sync
IQuest quest = btnQuest.getQuest();
IQuestLine qLine = gui.getQuestLine().getQuestLine();
int qID = QuestDatabase.INSTANCE.nextKey();
int lID = QuestLineDatabase.INSTANCE.getKey(qLine);
QuestLineEntry qe = new QuestLineEntry(mx, my, Math.max(btnQuest.width, btnQuest.height));
qLine.add(qe, qID);
btnQuest = null;
// Sync Quest
NBTTagCompound tag1 = new NBTTagCompound();
NBTTagCompound base1 = new NBTTagCompound();
base1.setTag("config", quest.writeToNBT(new NBTTagCompound(), EnumSaveType.CONFIG));
tag1.setTag("data", base1);
tag1.setInteger("action", EnumPacketAction.ADD.ordinal());
tag1.setInteger("questID", qID);
PacketSender.INSTANCE.sendToServer(new QuestingPacket(PacketTypeNative.QUEST_EDIT.GetLocation(), tag1));
// Sync Line
NBTTagCompound tag2 = new NBTTagCompound();
NBTTagCompound base2 = new NBTTagCompound();
base2.setTag("line", qLine.writeToNBT(new NBTTagCompound(), EnumSaveType.CONFIG));
tag2.setTag("data", base2);
tag2.setInteger("action", EnumPacketAction.EDIT.ordinal());
tag2.setInteger("lineID", lID);
PacketSender.INSTANCE.sendToServer(new QuestingPacket(PacketTypeNative.LINE_EDIT.GetLocation(), tag2));
}
}
Aggregations