use of betterquesting.api.questing.IQuestLineEntry in project BetterQuesting by Funwayguy.
the class QuestLine method writeToNBT.
@Override
public NBTTagCompound writeToNBT(NBTTagCompound json, EnumSaveType saveType) {
if (saveType != EnumSaveType.CONFIG) {
return json;
}
json.setTag("properties", info.writeToNBT(new NBTTagCompound(), saveType));
NBTTagList jArr = new NBTTagList();
for (Entry<Integer, IQuestLineEntry> entry : questList.entrySet()) {
NBTTagCompound qle = entry.getValue().writeToNBT(new NBTTagCompound(), saveType);
qle.setInteger("id", entry.getKey());
jArr.appendTag(qle);
}
json.setTag("quests", jArr);
return json;
}
use of betterquesting.api.questing.IQuestLineEntry in project BetterQuesting by Funwayguy.
the class GuiQuestLineEditorB method actionPerformed.
@Override
public void actionPerformed(GuiButton button) {
super.actionPerformed(button);
if (button.id == 1) {
createQuest();
} else if (button.id > 1) {
// Line listing (0 = quest, 1 = quest delete, 2 = registry)
int column = button.id & 7;
int id = (button.id >> 3) - 2;
if (// Edit quest
column == 0 || column == 3) {
if (id >= 0) {
IQuest q = QuestDatabase.INSTANCE.getValue(id);
if (q != null) {
mc.displayGuiScreen(new GuiQuest(this, id));
}
}
} else if (// Remove quest
column == 1 && line != null) {
line.removeKey(id);
// RefreshColumns();
SendChanges(EnumPacketAction.EDIT, lineID);
} else if (// Delete quest
column == 4 && id >= 0) {
NBTTagCompound tags = new NBTTagCompound();
// Delete quest
tags.setInteger("action", EnumPacketAction.REMOVE.ordinal());
tags.setInteger("questID", id);
PacketSender.INSTANCE.sendToServer(new QuestingPacket(PacketTypeNative.QUEST_EDIT.GetLocation(), tags));
} else if (// Add quest
column == 2 && line != null && id >= 0) {
IQuestLineEntry qe = new QuestLineEntry(0, 0);
int x1 = 0;
int y1 = 0;
topLoop: while (true) {
for (IQuestLineEntry qe2 : line.getAllValues()) {
int x2 = qe2.getPosX();
int y2 = qe2.getPosY();
int s2 = qe2.getSize();
if (x1 >= x2 && x1 < x2 + s2 && y1 >= y2 && y1 < y2 + s2) {
x1 += s2;
x2 += s2;
// We're in the way, move over and try again
continue topLoop;
}
}
break;
}
qe.setPosition(x1, y1);
line.add(qe, id);
RefreshColumns();
SendChanges(EnumPacketAction.EDIT, lineID);
}
}
}
use of betterquesting.api.questing.IQuestLineEntry in project BetterQuesting by Funwayguy.
the class ToolboxToolGrab method onMouseClick.
@Override
public void onMouseClick(int mx, int my, int click) {
if (click == 1 && grabbed != null) {
IQuestLineEntry qle = gui.getQuestLine().getQuestLine().getValue(grabID);
if (qle != null) {
// Reset position
grabbed.x = qle.getPosX();
grabbed.y = qle.getPosY();
}
grabbed = null;
return;
} else if (click != 0) {
return;
}
if (grabbed == null) {
grabbed = gui.getQuestLine().getButtonAt(mx, my);
grabID = grabbed == null ? -1 : QuestDatabase.INSTANCE.getKey(grabbed.getQuest());
} else {
IQuestLine qLine = gui.getQuestLine().getQuestLine();
int lID = QuestLineDatabase.INSTANCE.getKey(qLine);
IQuestLineEntry qle = gui.getQuestLine().getQuestLine().getValue(grabID);
if (qle != null) {
qle.setPosition(grabbed.x, grabbed.y);
// 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));
}
grabbed = null;
grabID = -1;
}
}
use of betterquesting.api.questing.IQuestLineEntry in project BetterQuesting by Funwayguy.
the class ToolboxToolScale method onMouseClick.
@Override
public void onMouseClick(int mx, int my, int click) {
if (click == 1) {
IQuestLineEntry qle = gui.getQuestLine().getQuestLine().getValue(grabID);
if (qle != null) {
// Reset size
grabbed.width = qle.getSize();
grabbed.height = qle.getSize();
}
grabbed = null;
return;
} else if (click != 0) {
return;
}
if (grabbed == null) {
grabbed = gui.getQuestLine().getButtonAt(mx, my);
grabID = grabbed == null ? -1 : QuestDatabase.INSTANCE.getKey(grabbed.getQuest());
} else {
IQuestLine qLine = gui.getQuestLine().getQuestLine();
int lID = QuestLineDatabase.INSTANCE.getKey(qLine);
IQuestLineEntry qle = gui.getQuestLine().getQuestLine().getValue(grabID);
if (qle != null) {
qle.setSize(Math.max(grabbed.width, grabbed.height));
// 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));
}
grabbed = null;
grabID = -1;
}
}
use of betterquesting.api.questing.IQuestLineEntry in project BetterQuesting by Funwayguy.
the class QuestLineButtonTree method RebuildTree.
public void RebuildTree() {
buttonTree.clear();
treeW = 0;
treeH = 0;
if (line == null) {
return;
}
for (int id : line.getAllKeys()) {
IQuest quest = QuestingAPI.getAPI(ApiReference.QUEST_DB).getValue(id);
IQuestLineEntry entry = line.getValue(id);
if (quest != null && entry != null) {
buttonTree.add(new GuiButtonQuestInstance(0, entry.getPosX(), entry.getPosY(), entry.getSize(), entry.getSize(), quest));
}
}
// Offset origin to 0,0 and establish bounds
for (GuiButtonQuestInstance btn : buttonTree) {
if (btn == null) {
continue;
}
treeW = Math.max(btn.x + btn.width, treeW);
treeH = Math.max(btn.y + btn.height, treeH);
for (GuiButtonQuestInstance b2 : buttonTree) {
if (b2 == null || btn == b2 || btn.getQuest() == null) {
continue;
}
if (btn.getQuest().getPrerequisites().contains(b2.getQuest())) {
btn.addParent(b2);
}
}
}
}
Aggregations