ChatboxPanelManager: Kill panels when logging out.
Otherwise key listeners stay running and that is not a good idea on the login screen
This commit is contained in:
@@ -32,8 +32,10 @@ import com.google.inject.Singleton;
|
|||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import net.runelite.api.Client;
|
import net.runelite.api.Client;
|
||||||
|
import net.runelite.api.GameState;
|
||||||
import net.runelite.api.ScriptID;
|
import net.runelite.api.ScriptID;
|
||||||
import net.runelite.api.VarClientInt;
|
import net.runelite.api.VarClientInt;
|
||||||
|
import net.runelite.api.events.GameStateChanged;
|
||||||
import net.runelite.api.events.ScriptCallbackEvent;
|
import net.runelite.api.events.ScriptCallbackEvent;
|
||||||
import net.runelite.api.vars.InputType;
|
import net.runelite.api.vars.InputType;
|
||||||
import net.runelite.api.widgets.JavaScriptCallback;
|
import net.runelite.api.widgets.JavaScriptCallback;
|
||||||
@@ -144,32 +146,46 @@ public class ChatboxPanelManager
|
|||||||
{
|
{
|
||||||
if (currentInput != null && "resetChatboxInput".equals(ev.getEventName()))
|
if (currentInput != null && "resetChatboxInput".equals(ev.getEventName()))
|
||||||
{
|
{
|
||||||
try
|
killCurrentPanel();
|
||||||
{
|
|
||||||
currentInput.close();
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
log.warn("Exception closing {}", currentInput.getClass(), e);
|
|
||||||
}
|
|
||||||
|
|
||||||
eventBus.unregister(currentInput);
|
|
||||||
if (currentInput instanceof KeyListener)
|
|
||||||
{
|
|
||||||
keyManager.unregisterKeyListener((KeyListener) currentInput);
|
|
||||||
}
|
|
||||||
if (currentInput instanceof MouseListener)
|
|
||||||
{
|
|
||||||
mouseManager.unregisterMouseListener((MouseListener) currentInput);
|
|
||||||
}
|
|
||||||
if (currentInput instanceof MouseWheelListener)
|
|
||||||
{
|
|
||||||
mouseManager.unregisterMouseWheelListener((MouseWheelListener) currentInput);
|
|
||||||
}
|
|
||||||
currentInput = null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Subscribe
|
||||||
|
private void onGameStateChanged(GameStateChanged ev)
|
||||||
|
{
|
||||||
|
if (currentInput != null && ev.getGameState() == GameState.LOGIN_SCREEN)
|
||||||
|
{
|
||||||
|
killCurrentPanel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void killCurrentPanel()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
currentInput.close();
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
log.warn("Exception closing {}", currentInput.getClass(), e);
|
||||||
|
}
|
||||||
|
|
||||||
|
eventBus.unregister(currentInput);
|
||||||
|
if (currentInput instanceof KeyListener)
|
||||||
|
{
|
||||||
|
keyManager.unregisterKeyListener((KeyListener) currentInput);
|
||||||
|
}
|
||||||
|
if (currentInput instanceof MouseListener)
|
||||||
|
{
|
||||||
|
mouseManager.unregisterMouseListener((MouseListener) currentInput);
|
||||||
|
}
|
||||||
|
if (currentInput instanceof MouseWheelListener)
|
||||||
|
{
|
||||||
|
mouseManager.unregisterMouseWheelListener((MouseWheelListener) currentInput);
|
||||||
|
}
|
||||||
|
currentInput = null;
|
||||||
|
}
|
||||||
|
|
||||||
public Widget getContainerWidget()
|
public Widget getContainerWidget()
|
||||||
{
|
{
|
||||||
return client.getWidget(WidgetInfo.CHATBOX_CONTAINER);
|
return client.getWidget(WidgetInfo.CHATBOX_CONTAINER);
|
||||||
|
|||||||
Reference in New Issue
Block a user