keyremapping: only update chatbox input and not player name
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
/*'
|
||||
/*
|
||||
* Copyright (c) 2018, Adam <Adam@sigterm.info>
|
||||
* Copyright (c) 2018, Abexlry <abexlry@gmail.com>
|
||||
* All rights reserved.
|
||||
@@ -33,7 +33,6 @@ import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.api.GameState;
|
||||
import net.runelite.api.IconID;
|
||||
import net.runelite.api.VarClientInt;
|
||||
import net.runelite.api.VarClientStr;
|
||||
import net.runelite.api.Varbits;
|
||||
@@ -159,7 +158,7 @@ public class KeyRemappingPlugin extends Plugin
|
||||
{
|
||||
if (chatboxFocused() && !typing)
|
||||
{
|
||||
chatboxInput.setText(getPlayerNameWithIcon() + ": " + PRESS_ENTER_TO_CHAT);
|
||||
setChatboxWidgetInput(chatboxInput, PRESS_ENTER_TO_CHAT);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -179,7 +178,7 @@ public class KeyRemappingPlugin extends Plugin
|
||||
Widget chatboxInput = client.getWidget(WidgetInfo.CHATBOX_INPUT);
|
||||
if (chatboxInput != null)
|
||||
{
|
||||
chatboxInput.setText(getPlayerNameWithIcon() + ": " + PRESS_ENTER_TO_CHAT);
|
||||
setChatboxWidgetInput(chatboxInput, PRESS_ENTER_TO_CHAT);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -192,28 +191,19 @@ public class KeyRemappingPlugin extends Plugin
|
||||
{
|
||||
final boolean isChatboxTransparent = client.isResized() && client.getVar(Varbits.TRANSPARENT_CHATBOX) == 1;
|
||||
final Color textColor = isChatboxTransparent ? JagexColors.CHAT_TYPED_TEXT_TRANSPARENT_BACKGROUND : JagexColors.CHAT_TYPED_TEXT_OPAQUE_BACKGROUND;
|
||||
chatboxInput.setText(getPlayerNameWithIcon() + ": " + ColorUtil.wrapWithColorTag(client.getVar(VarClientStr.CHATBOX_TYPED_TEXT) + "*", textColor));
|
||||
setChatboxWidgetInput(chatboxInput, ColorUtil.wrapWithColorTag(client.getVar(VarClientStr.CHATBOX_TYPED_TEXT) + "*", textColor));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private String getPlayerNameWithIcon()
|
||||
private void setChatboxWidgetInput(Widget widget, String input)
|
||||
{
|
||||
IconID icon;
|
||||
switch (client.getAccountType())
|
||||
String text = widget.getText();
|
||||
int idx = text.indexOf(':');
|
||||
if (idx != -1)
|
||||
{
|
||||
case IRONMAN:
|
||||
icon = IconID.IRONMAN;
|
||||
break;
|
||||
case ULTIMATE_IRONMAN:
|
||||
icon = IconID.ULTIMATE_IRONMAN;
|
||||
break;
|
||||
case HARDCORE_IRONMAN:
|
||||
icon = IconID.HARDCORE_IRONMAN;
|
||||
break;
|
||||
default:
|
||||
return client.getLocalPlayer().getName();
|
||||
String newText = text.substring(0, idx) + ": " + input;
|
||||
widget.setText(newText);
|
||||
}
|
||||
return icon + client.getLocalPlayer().getName();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user