Easier Edit Mode
soraphis opened this issue ยท 3 comments
i'm creating a questpack, and most of the quests are detection quests.
it's extremely tedious to switch through the ITEM and NORMAL tools all the time, this could be easier:
Double-Click (in NORMAL mode) to open the ItemTask View:
Proposed Code Changes (click me)
// ---------------
private long FirstClick = 0;
private ItemRequirement lastClicked;
// ---------------
@SideOnly(Side.CLIENT)
@Override
public void onClick(GuiQuestBook gui, EntityPlayer player, int mX, int mY, int b) {
boolean isOpBookWithShiftKeyDown = gui.isOpBook && GuiScreen.isShiftKeyDown();
boolean doubleClick = false;
if (! Quest.isEditing && !isOpBookWithShiftKeyDown) return;
ItemRequirement[] items = getEditFriendlyItems(this.items);
for (int i = 0; i < items.length; i++) {
ItemRequirement item = items[i];
if (! gui.inBounds(item.x, item.y, SIZE, SIZE, mX, mY)) continue;
// -------------------
if(lastClicked != item){
lastClicked = item;
FirstClick = System.currentTimeMillis();
}else if(System.currentTimeMillis - FirstClick < 1000){
doubleClick = true;
}
// -------------------
if (isOpBookWithShiftKeyDown) {
if (getProgress(player, i) == item.required) {
resetTask(QuestingData.getUserUUID(player), i);
} else {
completeTask(QuestingData.getUserUUID(player), i, item.required);
}
}else if(Quest.isEditing){
if(gui.getCurrentMode() == EditMode.ITEM || doubleClick){
gui.setEditMenu(new GuiEditMenuItem(gui, player, item.hasItem ? item.stack != null ? item.stack.copy() : null : item.fluid, i, getMenuTypeId(), item.required, item.precision));
}else if(gui.getCurrentMode() == EditMode.DELETE && (item.stack != null || item.fluid != null)){
ItemRequirement[] newItems = new ItemRequirement[this.items.length - 1];
System.arraycopy(this.items, 0, newItems, 0, newItems.length);
if(this.items.length - 1 > i && i >= 0){
System.arraycopy(this.items, i+1, newItems, i, this.items.length - 1 - i);
}
setItems(newItems);
SaveHelper.add(SaveHelper.EditType.TASK_ITEM_REMOVE);
}
}
break;
}
}
i restructured the method a bit, the important parts are wrapped in line-comments
https://github.com/lorddusk/HQM/blob/1.12/src/main/java/hardcorequesting/quests/Quest.java#L1164
change the condition from gui.getCurrentMode() != NORMAL
to gui.getCurrentMode() == RENAME || gui.getCurrentMode() == DELETE
this way you can select a task with a "wrong tool" selected. so you can open a task with e.g. the ITEM or LOCATION tool selected. -> less switching between tools.
https://github.com/lorddusk/HQM/blob/1.12/src/main/java/hardcorequesting/quests/QuestSet.java#L725
if you're renaming your quests, its possible to have the RENAME tool activate on the QuestSet View, (wich is not on the toolbar on the left, because it has no purpose here). if you've a useless tool selected, the editor should behave like the normal tool, this can be archived like this:
remove the if in L725 (and the else block), add following to the switch-case:
Proposed Code Changes (click me)
switch (gui.getCurrentMode()) {
/* current code here */
case NORMAL:
if (gui.isOpBook && GuiScreen.isShiftKeyDown()){
OPBookHelper.reverseQuestCompletion(quest, player);
break;
}
// drop through
default:
GuiQuestBook.selectedQuest = quest;
quest.onOpen(gui, player);
/*break; or better:*/ return;
duely is right. Please open a proper pull request for this, since it seems to me that you have the knowledge for it. It is just easier for all of us @soraphis
All right, I've had the time to sit down and take another look at this. I've accepted the first example, although I've modified it significantly as the item requirement is really irrelevant: if it's an actual double click, it's this one that we care about, so it's just the timing that we need. (And switched to player.ticksExisted).
However, it could do well to be extended to cover quest rewards as well as quest requirements. I'll look into this.
I've accepted the second one as that's sometimes painful.
However, the final one seems irrelevant. You talk about the RENAME tool in the quest set context -- which is a context where one might actually want to rename the name of the Quest Set? If it meant the overall book itself, you can currently "click here to open quests" even with the RENAME tool selected.
Perhaps that was improved in a previous build.