Merge pull request #2896 from buracc/dialog-events
events: Add Dialog events
This commit is contained in:
@@ -0,0 +1,48 @@
|
|||||||
|
package net.runelite.api;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
public enum DialogOption
|
||||||
|
{
|
||||||
|
NPC_CONTINUE(15138819, -1),
|
||||||
|
PLAYER_CONTINUE(14221315, -1),
|
||||||
|
QUEST(12648448, 0),
|
||||||
|
ITEM_ONE(12648448, -1),
|
||||||
|
ITEM_TWO(12648448, 0),
|
||||||
|
CHAT_OPTION_ONE(14352385, 1),
|
||||||
|
CHAT_OPTION_TWO(14352385, 2),
|
||||||
|
CHAT_OPTION_THREE(14352385, 3),
|
||||||
|
CHAT_OPTION_FOUR(14352385, 4),
|
||||||
|
CHAT_OPTION_FIVE(14352385, 5),
|
||||||
|
PLAIN_CONTINUE(15007746, -1),
|
||||||
|
PLAIN_CONTINUE_TWO(720900, -1);
|
||||||
|
|
||||||
|
private final int widgetUid;
|
||||||
|
private final int menuIndex;
|
||||||
|
|
||||||
|
DialogOption(int widgetUid, int menuIndex)
|
||||||
|
{
|
||||||
|
this.widgetUid = widgetUid;
|
||||||
|
this.menuIndex = menuIndex;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getWidgetUid()
|
||||||
|
{
|
||||||
|
return widgetUid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMenuIndex()
|
||||||
|
{
|
||||||
|
return menuIndex;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public static DialogOption of(int widgetUid, int menuIndex)
|
||||||
|
{
|
||||||
|
return Arrays.stream(values())
|
||||||
|
.filter(option -> option.getWidgetUid() == widgetUid && option.getMenuIndex() == menuIndex)
|
||||||
|
.findFirst()
|
||||||
|
.orElse(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
package net.runelite.api.events;
|
||||||
|
|
||||||
|
import lombok.Value;
|
||||||
|
import net.runelite.api.DialogOption;
|
||||||
|
|
||||||
|
@Value
|
||||||
|
public class DialogProcessed implements Event
|
||||||
|
{
|
||||||
|
DialogOption dialogOption;
|
||||||
|
}
|
||||||
@@ -24,6 +24,8 @@
|
|||||||
*/
|
*/
|
||||||
package net.runelite.mixins;
|
package net.runelite.mixins;
|
||||||
|
|
||||||
|
import net.runelite.api.DialogOption;
|
||||||
|
import net.runelite.api.events.DialogProcessed;
|
||||||
import net.runelite.api.events.DynamicObjectAnimationChanged;
|
import net.runelite.api.events.DynamicObjectAnimationChanged;
|
||||||
import net.runelite.api.mixins.Copy;
|
import net.runelite.api.mixins.Copy;
|
||||||
import net.runelite.api.mixins.FieldHook;
|
import net.runelite.api.mixins.FieldHook;
|
||||||
@@ -100,4 +102,23 @@ public abstract class RSDynamicObjectMixin implements RSDynamicObject
|
|||||||
{
|
{
|
||||||
return (int) (getSequenceDefinition() == null ? -1 : getSequenceDefinition().getHash());
|
return (int) (getSequenceDefinition() == null ? -1 : getSequenceDefinition().getHash());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
@MethodHook("resumePauseWidget")
|
||||||
|
public static void onDialogProcessed(int widgetUid, int menuIndex)
|
||||||
|
{
|
||||||
|
DialogOption dialogOption = DialogOption.of(widgetUid, menuIndex);
|
||||||
|
if (dialogOption != null)
|
||||||
|
{
|
||||||
|
client.getCallbacks().post(new DialogProcessed(dialogOption));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
client.getLogger().debug(
|
||||||
|
"Unknown or unmapped dialog option for widgetUid: {} and menuIndex {}",
|
||||||
|
widgetUid,
|
||||||
|
menuIndex
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user