crowdsourcing/dialog: track start & end of conversations (#13763)

This commit is contained in:
andmcadams
2021-06-22 11:37:51 -05:00
committed by GitHub
parent 467ebec218
commit e1fe9c9fb1
4 changed files with 69 additions and 4 deletions

View File

@@ -184,6 +184,11 @@ public class WidgetID
static final int TOP_BAR = 12;
}
static class DialogOption
{
static final int OPTIONS = 1;
}
static class DialogNPC
{
static final int HEAD_MODEL = 6;
@@ -191,6 +196,13 @@ public class WidgetID
static final int TEXT = 5;
}
static class DialogPlayer
{
static final int NAME = 3;
static final int TEXT = 5;
static final int HEAD_MODEL = 6;
}
static class LogoutPanel
{
static final int WORLD_SWITCHER_BUTTON = 3;

View File

@@ -334,6 +334,7 @@ public enum WidgetInfo
COMBAT_AUTO_RETALIATE(WidgetID.COMBAT_GROUP_ID, WidgetID.Combat.AUTO_RETALIATE),
DIALOG_OPTION(WidgetID.DIALOG_OPTION_GROUP_ID, 0),
DIALOG_OPTION_OPTIONS(WidgetID.DIALOG_OPTION_GROUP_ID, WidgetID.DialogOption.OPTIONS),
DIALOG_SPRITE(WidgetID.DIALOG_SPRITE_GROUP_ID, 0),
DIALOG_SPRITE_SPRITE(WidgetID.DIALOG_SPRITE_GROUP_ID, WidgetID.DialogSprite.SPRITE),
@@ -344,6 +345,7 @@ public enum WidgetInfo
DIALOG_NPC_HEAD_MODEL(WidgetID.DIALOG_NPC_GROUP_ID, WidgetID.DialogNPC.HEAD_MODEL),
DIALOG_PLAYER(WidgetID.DIALOG_PLAYER_GROUP_ID, 0),
DIALOG_PLAYER_TEXT(WidgetID.DIALOG_PLAYER_GROUP_ID, WidgetID.DialogPlayer.TEXT),
PRIVATE_CHAT_MESSAGE(WidgetID.PRIVATE_CHAT, 0),
@@ -535,7 +537,7 @@ public enum WidgetInfo
HEALTH_OVERLAY_BAR(WidgetID.HEALTH_OVERLAY_BAR_GROUP_ID, WidgetID.EncounterHealthBar.CONTAINER),
TRAILBLAZER_AREA_TELEPORT(WidgetID.TRAILBLAZER_AREAS_GROUP_ID, WidgetID.TrailblazerAreas.TELEPORT),
MULTICOMBAT_FIXED(WidgetID.FIXED_VIEWPORT_GROUP_ID, WidgetID.FixedViewport.MULTICOMBAT_INDICATOR),
MULTICOMBAT_RESIZEABLE_MODERN(WidgetID.RESIZABLE_VIEWPORT_BOTTOM_LINE_GROUP_ID, WidgetID.ResizableViewport.MULTICOMBAT_INDICATOR),
MULTICOMBAT_RESIZEABLE_CLASSIC(WidgetID.RESIZABLE_VIEWPORT_OLD_SCHOOL_BOX_GROUP_ID, WidgetID.ResizableViewport.MULTICOMBAT_INDICATOR),

View File

@@ -29,7 +29,6 @@ import javax.inject.Inject;
import net.runelite.api.Client;
import net.runelite.api.events.GameTick;
import net.runelite.api.widgets.Widget;
import net.runelite.api.widgets.WidgetID;
import net.runelite.api.widgets.WidgetInfo;
import net.runelite.client.eventbus.Subscribe;
import net.runelite.client.plugins.crowdsourcing.CrowdsourcingManager;
@@ -44,6 +43,7 @@ public class CrowdsourcingDialogue
@Inject
private CrowdsourcingManager manager;
private boolean inDialogue = false;
private String lastNpcDialogueText = null;
private String lastPlayerDialogueText = null;
private Widget[] dialogueOptions;
@@ -58,6 +58,23 @@ public class CrowdsourcingDialogue
public void onGameTick(GameTick tick)
{
Widget npcDialogueTextWidget = client.getWidget(WidgetInfo.DIALOG_NPC_TEXT);
Widget playerDialogueTextWidget = client.getWidget(WidgetInfo.DIALOG_PLAYER_TEXT);
Widget playerDialogueOptionsWidget = client.getWidget(WidgetInfo.DIALOG_OPTION_OPTIONS);
// If we were not in a conversation, but now one of these widgets is not null, we have started a conversation.
// Else if we were in a conversation, but now there is no widget, we have left the conversation.
if (!inDialogue && (npcDialogueTextWidget != null || playerDialogueTextWidget != null || playerDialogueOptionsWidget != null))
{
inDialogue = true;
manager.storeEvent(new StartEndData(true));
}
else if (inDialogue && npcDialogueTextWidget == null && playerDialogueTextWidget == null
&& playerDialogueOptionsWidget == null)
{
inDialogue = false;
manager.storeEvent(new StartEndData(false));
}
if (npcDialogueTextWidget != null && !npcDialogueTextWidget.getText().equals(lastNpcDialogueText))
{
lastNpcDialogueText = npcDialogueTextWidget.getText();
@@ -66,7 +83,6 @@ public class CrowdsourcingDialogue
manager.storeEvent(data);
}
Widget playerDialogueTextWidget = client.getWidget(WidgetID.DIALOG_PLAYER_GROUP_ID, 4);
if (playerDialogueTextWidget != null && !playerDialogueTextWidget.getText().equals(lastPlayerDialogueText))
{
lastPlayerDialogueText = playerDialogueTextWidget.getText();
@@ -74,7 +90,6 @@ public class CrowdsourcingDialogue
manager.storeEvent(data);
}
Widget playerDialogueOptionsWidget = client.getWidget(WidgetID.DIALOG_OPTION_GROUP_ID, 1);
if (playerDialogueOptionsWidget != null && playerDialogueOptionsWidget.getChildren() != dialogueOptions)
{
dialogueOptions = playerDialogueOptionsWidget.getChildren();

View File

@@ -0,0 +1,36 @@
/*
* Copyright (c) 2021, Weird Gloop <admin@weirdgloop.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.client.plugins.crowdsourcing.dialogue;
import lombok.AllArgsConstructor;
import lombok.Data;
@Data
@AllArgsConstructor
public class StartEndData
{
private final boolean isStart;
}