runelite-client: Always call done after changed in ChatboxInptutManager

Also changed doesn't need to be called twice when escaping from the menu
This commit is contained in:
Max Weber
2018-07-29 15:40:19 -06:00
parent 0e9417963b
commit 6b045fbb96

View File

@@ -116,30 +116,23 @@ public class ChatboxInputManager
int stringStackSize = client.getStringStackSize(); int stringStackSize = client.getStringStackSize();
int typedKey = client.getIntStack()[--intStackSize]; int typedKey = client.getIntStack()[--intStackSize];
String str = client.getStringStack()[--stringStackSize]; String str = client.getStringStack()[--stringStackSize];
int retval = 0; boolean isDone = false;
switch (typedKey) switch (typedKey)
{ {
case 27: // Escape case 27: // Escape
str = ""; str = "";
if (changed != null)
{
changed.accept(str);
}
// fallthrough // fallthrough
case '\n': case '\n':
if (done != null)
{
done.accept(str);
}
this.open = false; this.open = false;
retval = 1; isDone = true;
break; break;
case '\b': case '\b':
if (str.length() > 0) if (str.length() > 0)
{ {
str = str.substring(0, str.length() - 1); str = str.substring(0, str.length() - 1);
} }
break;
default: default:
// If we wanted to do numbers only, we could add a limit here // If we wanted to do numbers only, we could add a limit here
if (typedKey >= 32 && (str.length() < characterLimit)) if (typedKey >= 32 && (str.length() < characterLimit))
@@ -153,8 +146,13 @@ public class ChatboxInputManager
changed.accept(str); changed.accept(str);
} }
if (isDone && done != null)
{
done.accept(str);
}
client.getStringStack()[stringStackSize++] = str; client.getStringStack()[stringStackSize++] = str;
client.getIntStack()[intStackSize++] = retval; client.getIntStack()[intStackSize++] = isDone ? 1 : 0;
client.setIntStackSize(intStackSize); client.setIntStackSize(intStackSize);
client.setStringStackSize(stringStackSize); client.setStringStackSize(stringStackSize);
} }