use of betterquesting.api.questing.IQuestLine 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.IQuestLine 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.IQuestLine 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);
}
use of betterquesting.api.questing.IQuestLine in project BetterQuesting by Funwayguy.
the class ToolboxToolNew method onMouseClick.
@Override
public void onMouseClick(int mx, int my, int click) {
if (click != 0) {
return;
}
int snap = ToolboxGuiMain.getSnapValue();
int modX = ((mx % snap) + snap) % snap;
int modY = ((my % snap) + snap) % snap;
mx -= modX;
my -= modY;
// Pre-sync
IQuestLine qLine = gui.getQuestLine().getQuestLine();
IQuest quest = new QuestInstance();
int qID = QuestDatabase.INSTANCE.nextKey();
int lID = QuestLineDatabase.INSTANCE.getKey(qLine);
QuestLineEntry qe = new QuestLineEntry(mx, my, 24);
qLine.add(qe, qID);
// 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));
}
use of betterquesting.api.questing.IQuestLine in project BetterQuesting by Funwayguy.
the class ToolboxToolRemove method onMouseClick.
@Override
public void onMouseClick(int mx, int my, int click) {
if (click != 0) {
return;
}
IQuestLine line = gui.getQuestLine().getQuestLine();
GuiButtonQuestInstance btn = gui.getQuestLine().getButtonAt(mx, my);
if (line != null && btn != null) {
int qID = QuestDatabase.INSTANCE.getKey(btn.getQuest());
line.removeKey(qID);
NBTTagCompound tags = new NBTTagCompound();
tags.setInteger("action", EnumPacketAction.EDIT.ordinal());
NBTTagCompound base = new NBTTagCompound();
base.setTag("line", line.writeToNBT(new NBTTagCompound(), EnumSaveType.CONFIG));
tags.setTag("data", base);
tags.setInteger("lineID", QuestLineDatabase.INSTANCE.getKey(line));
PacketSender.INSTANCE.sendToServer(new QuestingPacket(PacketTypeNative.LINE_EDIT.GetLocation(), tags));
}
}
Aggregations