timestamp: use steam client chat timestamp support
The chat building scripts have variables now for message timestamp, so we can just assign our timestamp to those instead.
This commit is contained in:
@@ -505,6 +505,8 @@ public class Instructions implements Opcodes
|
|||||||
add(CHAT_SETMESSAGEFILTER, "chat_setmessagefilter");
|
add(CHAT_SETMESSAGEFILTER, "chat_setmessagefilter");
|
||||||
add(CHAT_GETMESSAGEFILTER, "chat_getmessagefilter");
|
add(CHAT_GETMESSAGEFILTER, "chat_getmessagefilter");
|
||||||
add(WRITECONSOLE, "writeconsole");
|
add(WRITECONSOLE, "writeconsole");
|
||||||
|
add(CHAT_GETHISTORYEX_BYTYPEANDLINE, "chat_gethistoryex_bytypeandline");
|
||||||
|
add(CHAT_GETHISTORYEX_BYUID, "chat_gethistoryex_byuid");
|
||||||
add(GETWINDOWMODE, "getwindowmode");
|
add(GETWINDOWMODE, "getwindowmode");
|
||||||
add(SETWINDOWMODE, "setwindowmode");
|
add(SETWINDOWMODE, "setwindowmode");
|
||||||
add(GETDEFAULTWINDOWMODE, "getdefaultwindowmode");
|
add(GETDEFAULTWINDOWMODE, "getdefaultwindowmode");
|
||||||
|
|||||||
@@ -497,6 +497,8 @@ public interface Opcodes
|
|||||||
int CHAT_SETMESSAGEFILTER = 5021;
|
int CHAT_SETMESSAGEFILTER = 5021;
|
||||||
int CHAT_GETMESSAGEFILTER = 5022;
|
int CHAT_GETMESSAGEFILTER = 5022;
|
||||||
int WRITECONSOLE = 5023;
|
int WRITECONSOLE = 5023;
|
||||||
|
int CHAT_GETHISTORYEX_BYTYPEANDLINE = 5030;
|
||||||
|
int CHAT_GETHISTORYEX_BYUID = 5031;
|
||||||
int GETWINDOWMODE = 5306;
|
int GETWINDOWMODE = 5306;
|
||||||
int SETWINDOWMODE = 5307;
|
int SETWINDOWMODE = 5307;
|
||||||
int GETDEFAULTWINDOWMODE = 5308;
|
int GETDEFAULTWINDOWMODE = 5308;
|
||||||
|
|||||||
@@ -36,13 +36,11 @@ import javax.inject.Inject;
|
|||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import net.runelite.api.Client;
|
import net.runelite.api.Client;
|
||||||
import net.runelite.api.MessageNode;
|
import net.runelite.api.MessageNode;
|
||||||
import net.runelite.api.ScriptID;
|
|
||||||
import net.runelite.api.Varbits;
|
import net.runelite.api.Varbits;
|
||||||
import net.runelite.api.events.ScriptPreFired;
|
|
||||||
import net.runelite.client.events.ConfigChanged;
|
|
||||||
import net.runelite.api.events.ScriptCallbackEvent;
|
import net.runelite.api.events.ScriptCallbackEvent;
|
||||||
import net.runelite.client.config.ConfigManager;
|
import net.runelite.client.config.ConfigManager;
|
||||||
import net.runelite.client.eventbus.Subscribe;
|
import net.runelite.client.eventbus.Subscribe;
|
||||||
|
import net.runelite.client.events.ConfigChanged;
|
||||||
import net.runelite.client.plugins.Plugin;
|
import net.runelite.client.plugins.Plugin;
|
||||||
import net.runelite.client.plugins.PluginDescriptor;
|
import net.runelite.client.plugins.PluginDescriptor;
|
||||||
import net.runelite.client.util.ColorUtil;
|
import net.runelite.client.util.ColorUtil;
|
||||||
@@ -64,8 +62,6 @@ public class TimestampPlugin extends Plugin
|
|||||||
@Getter
|
@Getter
|
||||||
private SimpleDateFormat formatter;
|
private SimpleDateFormat formatter;
|
||||||
|
|
||||||
private MessageNode currentlyBuildingMessage = null;
|
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
public TimestampConfig provideConfig(final ConfigManager configManager)
|
public TimestampConfig provideConfig(final ConfigManager configManager)
|
||||||
{
|
{
|
||||||
@@ -102,51 +98,18 @@ public class TimestampPlugin extends Plugin
|
|||||||
}
|
}
|
||||||
|
|
||||||
int uid = client.getIntStack()[client.getIntStackSize() - 1];
|
int uid = client.getIntStack()[client.getIntStackSize() - 1];
|
||||||
currentlyBuildingMessage = client.getMessages().get(uid);
|
final MessageNode messageNode = client.getMessages().get(uid);
|
||||||
}
|
assert messageNode != null : "chat message build for unknown message";
|
||||||
|
|
||||||
@Subscribe
|
String timestamp = generateTimestamp(messageNode.getTimestamp(), ZoneId.systemDefault());
|
||||||
private void onScriptPreFired(ScriptPreFired ev)
|
|
||||||
{
|
|
||||||
int numStringArgs;
|
|
||||||
int messagePrefixArg = 0;
|
|
||||||
switch (ev.getScriptId())
|
|
||||||
{
|
|
||||||
case ScriptID.CHATBOX_BUILD_LINE_WITHOUT_USER:
|
|
||||||
numStringArgs = 1;
|
|
||||||
break;
|
|
||||||
case ScriptID.CHATBOX_BUILD_LINE_WITH_USER:
|
|
||||||
numStringArgs = 2;
|
|
||||||
break;
|
|
||||||
case ScriptID.CHATBOX_BUILD_LINE_WITH_CLAN:
|
|
||||||
numStringArgs = 3;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (currentlyBuildingMessage == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
MessageNode messageNode = currentlyBuildingMessage;
|
|
||||||
currentlyBuildingMessage = null;
|
|
||||||
|
|
||||||
String[] stringStack = client.getStringStack();
|
|
||||||
int stringArgStart = client.getStringStackSize() - numStringArgs;
|
|
||||||
|
|
||||||
String timestamp = generateTimestamp(messageNode.getTimestamp(), ZoneId.systemDefault()) + " ";
|
|
||||||
|
|
||||||
Color timestampColour = getTimestampColour();
|
Color timestampColour = getTimestampColour();
|
||||||
if (timestampColour != null)
|
if (timestampColour != null)
|
||||||
{
|
{
|
||||||
timestamp = ColorUtil.wrapWithColorTag(timestamp, timestampColour);
|
timestamp = ColorUtil.wrapWithColorTag(timestamp, timestampColour);
|
||||||
}
|
}
|
||||||
|
|
||||||
String segment = stringStack[stringArgStart + messagePrefixArg];
|
client.getStringStack()[client.getStringStackSize() - 1] = timestamp;
|
||||||
segment = timestamp + segment;
|
|
||||||
stringStack[stringArgStart + messagePrefixArg] = segment;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Color getTimestampColour()
|
private Color getTimestampColour()
|
||||||
|
|||||||
@@ -343,9 +343,9 @@ LABEL319:
|
|||||||
jump LABEL1598
|
jump LABEL1598
|
||||||
LABEL323:
|
LABEL323:
|
||||||
iload 10
|
iload 10
|
||||||
5031
|
chat_gethistoryex_byuid
|
||||||
istore 21
|
istore 21
|
||||||
sstore 18
|
sstore 18 ; timestamp
|
||||||
istore 15
|
istore 15
|
||||||
sstore 15
|
sstore 15
|
||||||
sstore 14
|
sstore 14
|
||||||
@@ -390,9 +390,11 @@ LABEL341:
|
|||||||
jump LABEL1594
|
jump LABEL1594
|
||||||
LABEL355:
|
LABEL355:
|
||||||
iload 10 ; message uid
|
iload 10 ; message uid
|
||||||
|
sload 18 ; message timestamp
|
||||||
sconst "chatMessageBuilding"
|
sconst "chatMessageBuilding"
|
||||||
runelite_callback
|
runelite_callback
|
||||||
pop_int ; pop uid
|
pop_int ; pop uid
|
||||||
|
sstore 18 ; message timestamp
|
||||||
iload 11
|
iload 11
|
||||||
switch
|
switch
|
||||||
1: LABEL358
|
1: LABEL358
|
||||||
|
|||||||
@@ -381,9 +381,9 @@ LABEL344:
|
|||||||
jump LABEL566
|
jump LABEL566
|
||||||
LABEL350:
|
LABEL350:
|
||||||
iload 12
|
iload 12
|
||||||
5031
|
chat_gethistoryex_byuid
|
||||||
istore 15
|
istore 15
|
||||||
sstore 2
|
sstore 2 ; timestamp
|
||||||
istore 14
|
istore 14
|
||||||
sstore 0
|
sstore 0
|
||||||
sstore 3
|
sstore 3
|
||||||
@@ -413,9 +413,11 @@ CHAT_FILTER:
|
|||||||
jump LABEL562
|
jump LABEL562
|
||||||
LABEL368:
|
LABEL368:
|
||||||
iload 12 ; message uid
|
iload 12 ; message uid
|
||||||
|
sload 2 ; message timestamp
|
||||||
sconst "chatMessageBuilding"
|
sconst "chatMessageBuilding"
|
||||||
runelite_callback
|
runelite_callback
|
||||||
pop_int
|
pop_int
|
||||||
|
sstore 2 ; message timestamp
|
||||||
iload 18
|
iload 18
|
||||||
switch
|
switch
|
||||||
3: LABEL371
|
3: LABEL371
|
||||||
|
|||||||
Reference in New Issue
Block a user