Skip to content

Commit faa4c07

Browse files
committed
refactor: move social list management to GameInterface
1 parent d2bf085 commit faa4c07

File tree

4 files changed

+292
-304
lines changed

4 files changed

+292
-304
lines changed

src/main/java/org/runejs/client/Class17.java

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,6 @@
11
package org.runejs.client;
22

3-
import org.runejs.client.cache.media.gameInterface.GameInterface;
4-
import org.runejs.client.frame.ChatBox;
5-
import org.runejs.client.language.English;
63
import org.runejs.client.media.renderable.actor.Player;
7-
import org.runejs.client.message.outbound.chat.ModifySocialListOutboundMessage;
8-
import org.runejs.client.net.OutgoingPackets;
9-
import org.runejs.client.scene.SceneCluster;
10-
import org.runejs.client.util.TextUtils;
114

125
import java.awt.*;
136

@@ -24,35 +17,6 @@ public static int method274() {
2417
return Class49.anInt1147++;
2518
}
2619

27-
public static void method275(long arg1) {
28-
if(arg1 != 0L) {
29-
if(MovedStatics.anInt1008 >= 100)
30-
ChatBox.addChatMessage("", English.yourIgnoreListIsFull.toString(), 0);
31-
else {
32-
String class1 = TextUtils.formatName(TextUtils.longToName(arg1));
33-
for(int i = 0; i < MovedStatics.anInt1008; i++) {
34-
if(arg1 == Player.ignores[i]) {
35-
ChatBox.addChatMessage("", class1 + English.suffixIsAlreadyOnYourIgnoreList, 0);
36-
return;
37-
}
38-
}
39-
for(int i = 0; Player.friendsCount > i; i++) {
40-
if(Class59.friends[i] == arg1) {
41-
ChatBox.addChatMessage("", English.pleaseRemove + class1 + English.fromYourFriendListFirst, 0);
42-
return;
43-
}
44-
}
45-
if(!class1.equals(Player.localPlayer.playerName)) {
46-
Player.ignores[MovedStatics.anInt1008++] = arg1;
47-
GameInterface.redrawTabArea = true;
48-
49-
OutgoingPackets.sendMessage(
50-
new ModifySocialListOutboundMessage(arg1, ModifySocialListOutboundMessage.SocialList.IGNORE, ModifySocialListOutboundMessage.SocialListAction.ADD));
51-
}
52-
}
53-
}
54-
}
55-
5620
public static void animatePlayers(int playerIndex) {
5721
for(int currentPlayerIndex = playerIndex; Player.localPlayerCount > currentPlayerIndex; currentPlayerIndex++) {
5822
int actualIndex;

src/main/java/org/runejs/client/Main.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1604,7 +1604,7 @@ else if(ChatBox.dialogueId != -1)
16041604
moveTowardsTarget();
16051605
for(int i_19_ = 0; i_19_ < 5; i_19_++)
16061606
SceneCamera.customCameraTimer[i_19_]++;
1607-
MovedStatics.manageTextInputs();
1607+
GameInterface.manageTextInputs();
16081608
int i_20_ = Npc.method400(-1);
16091609
int i_21_ = Class17.method274();
16101610
if(i_20_ > 4500 && i_21_ > 4500) {

src/main/java/org/runejs/client/MovedStatics.java

Lines changed: 1 addition & 262 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,15 @@
44
import org.runejs.client.cache.media.gameInterface.GameInterface;
55
import org.runejs.client.cache.media.gameInterface.GameInterfaceArea;
66
import org.runejs.client.cache.media.gameInterface.GameInterfaceType;
7-
import org.runejs.client.chat.ChatColorEffect;
8-
import org.runejs.client.chat.ChatShapeEffect;
97
import org.runejs.client.frame.Minimap;
108
import org.runejs.client.frame.ScreenController;
119
import org.runejs.client.frame.ScreenMode;
12-
import org.runejs.client.frame.console.Console;
1310
import org.runejs.client.frame.tab.parts.TabParts;
1411
import org.runejs.client.input.MouseHandler;
1512
import org.runejs.client.io.Buffer;
1613
import org.runejs.client.media.Rasterizer;
1714
import org.runejs.client.media.renderable.Item;
1815
import org.runejs.client.media.renderable.Model;
19-
import org.runejs.client.message.outbound.chat.*;
20-
import org.runejs.client.message.outbound.widget.input.*;
2116
import org.runejs.client.net.UpdateServer;
2217
import org.runejs.client.node.HashTable;
2318
import org.runejs.client.node.NodeCache;
@@ -34,7 +29,6 @@
3429
import org.runejs.client.media.renderable.GameObject;
3530
import org.runejs.client.media.renderable.Renderable;
3631
import org.runejs.client.net.ISAAC;
37-
import org.runejs.client.net.OutgoingPackets;
3832
import org.runejs.client.net.PacketBuffer;
3933
import org.runejs.client.scene.*;
4034
import org.runejs.client.scene.camera.CameraRotation;
@@ -44,7 +38,6 @@
4438
import org.runejs.client.util.BitUtils;
4539
import org.runejs.client.util.Signlink;
4640
import org.runejs.client.util.SignlinkNode;
47-
import org.runejs.client.util.TextUtils;
4841
import org.runejs.client.cache.def.*;
4942
import org.runejs.client.media.renderable.actor.*;
5043
import org.runejs.client.scene.tile.*;
@@ -581,21 +574,6 @@ public static String method204(int arg0) {
581574
return (0xff & arg0 >> 24) + Native.period + ((arg0 & 0xffca88) >> 16) + Native.period + ((0xfff8 & arg0) >> 8) + Native.period + (0xff & arg0);
582575
}
583576

584-
public static void method838(long arg1) {
585-
for (int i = 0; i < anInt1008; i++) {
586-
if (Player.ignores[i] == arg1) {
587-
GameInterface.redrawTabArea = true;
588-
anInt1008--;
589-
for (int i_16_ = i; anInt1008 > i_16_; i_16_++)
590-
Player.ignores[i_16_] = Player.ignores[1 + i_16_];
591-
592-
OutgoingPackets.sendMessage(
593-
new ModifySocialListOutboundMessage(arg1, ModifySocialListOutboundMessage.SocialList.IGNORE, ModifySocialListOutboundMessage.SocialListAction.REMOVE));
594-
break;
595-
}
596-
}
597-
}
598-
599577
public static ImageRGB[] method526(CacheArchive arg0, String arg2, String arg3) {
600578
int i = arg0.getHash(arg2);
601579
int i_4_ = arg0.method179(i, arg3);
@@ -714,38 +692,6 @@ else if (lightness > 126)
714692
return (0xff80 & hsl) + lightness;
715693
}
716694

717-
public static void addFriend(long name) {
718-
if(name != 0L) {
719-
if(Player.friendsCount >= 100 && Class44.anInt1049 != 1 || Player.friendsCount >= 200) {
720-
ChatBox.addChatMessage("", English.friendsListIsFull, 0);
721-
} else {
722-
String username = TextUtils.formatName(TextUtils.longToName(name));
723-
for(int i = 0; Player.friendsCount > i; i++) {
724-
if(Class59.friends[i] == name) {
725-
ChatBox.addChatMessage("", username + English.isAlreadyOnYourFriendList, 0);
726-
return;
727-
}
728-
}
729-
for(int i = 0; anInt1008 > i; i++) {
730-
if(Player.ignores[i] == name) {
731-
ChatBox.addChatMessage("", English.pleaseRemove + username + English.suffixFromYourIgnoreListFirst, 0);
732-
return;
733-
}
734-
}
735-
if(!username.equals(Player.localPlayer.playerName)) {
736-
Player.friendUsernames[Player.friendsCount] = username;
737-
Class59.friends[Player.friendsCount] = name;
738-
Player.friendWorlds[Player.friendsCount] = 0;
739-
Player.friendsCount++;
740-
GameInterface.redrawTabArea = true;
741-
742-
OutgoingPackets.sendMessage(
743-
new ModifySocialListOutboundMessage(name, ModifySocialListOutboundMessage.SocialList.FRIEND, ModifySocialListOutboundMessage.SocialListAction.ADD));
744-
}
745-
}
746-
}
747-
}
748-
749695
public static void method1013() {
750696
int lasthash = -1;
751697
if (MovedStatics.itemSelected == 0 && Main.widgetSelected == 0) {
@@ -1354,214 +1300,7 @@ public static void drawMenu(int xOffSet, int yOffSet) {
13541300
}
13551301
}
13561302

1357-
public static void manageTextInputs() {
1358-
while(method416()) {
1359-
if(ItemDefinition.anInt2854 == 28) {
1360-
break;
1361-
}
1362-
if(Console.console.consoleOpen) {
1363-
Console.console.handleInput();
1364-
break;
1365-
}
1366-
if(GameInterface.gameScreenInterfaceId != -1 && HuffmanEncoding.reportAbuseInterfaceID == GameInterface.gameScreenInterfaceId) {
1367-
if(ItemDefinition.anInt2854 == 85 && Native.reportedName.length() > 0)
1368-
Native.reportedName = Native.reportedName.substring(0, -1 + Native.reportedName.length());
1369-
if((Class40_Sub5_Sub15.method735(Class59.anInt1388) || Class59.anInt1388 == 32) && Native.reportedName.length() < 12)
1370-
Native.reportedName = Native.reportedName + (char) Class59.anInt1388;
1371-
} else if(ChatBox.messagePromptRaised) {
1372-
if(ItemDefinition.anInt2854 == 85 && ChatBox.chatMessage.length() > 0) {
1373-
ChatBox.chatMessage = ChatBox.chatMessage.substring(0, -1 + ChatBox.chatMessage.length());
1374-
ChatBox.redrawChatbox = true;
1375-
}
1376-
if(Player.method793(Class59.anInt1388) && ChatBox.chatMessage.length() < 80) {
1377-
ChatBox.chatMessage = ChatBox.chatMessage + (char) Class59.anInt1388;
1378-
ChatBox.redrawChatbox = true;
1379-
}
1380-
if(ItemDefinition.anInt2854 == 84) {
1381-
ChatBox.messagePromptRaised = false;
1382-
ChatBox.redrawChatbox = true;
1383-
if(Class37.anInt876 == 1) {
1384-
long l = RSString.nameToLong(ChatBox.chatMessage);
1385-
addFriend(l);
1386-
}
1387-
if(Class37.anInt876 == 2 && Player.friendsCount > 0) {
1388-
long l = RSString.nameToLong(ChatBox.chatMessage);
1389-
GameInterface.removeFriend(l);
1390-
}
1391-
if(Class37.anInt876 == 3 && ChatBox.chatMessage.length() > 0) {
1392-
// private messages
1393-
ChatBox.filterInput();
1394-
1395-
OutgoingPackets.sendMessage(new SendPrivateMessageOutboundMessage(PacketBuffer.aLong2241, ChatBox.chatboxInput));
1396-
1397-
if(ChatBox.privateChatMode == 2) {
1398-
ChatBox.privateChatMode = 1;
1399-
redrawChatbox = true;
1400-
1401-
OutgoingPackets.sendMessage(new SetChatOptionsOutboundMessage(
1402-
ChatBox.publicChatMode,
1403-
ChatBox.privateChatMode,
1404-
ChatBox.tradeMode
1405-
));
1406-
}
1407-
}
1408-
if(Class37.anInt876 == 4 && anInt1008 < 100) {
1409-
long l = RSString.nameToLong(ChatBox.chatMessage);
1410-
Class17.method275(l);
1411-
}
1412-
if(Class37.anInt876 == 5 && anInt1008 > 0) {
1413-
long l = RSString.nameToLong(ChatBox.chatMessage);
1414-
method838(l);
1415-
}
1416-
}
1417-
} else if(ChatBox.inputType == 1) {
1418-
if(ItemDefinition.anInt2854 == 85 && ChatBox.inputMessage.length() > 0) {
1419-
ChatBox.inputMessage = ChatBox.inputMessage.substring(0, ChatBox.inputMessage.length() - 1);
1420-
ChatBox.redrawChatbox = true;
1421-
}
1422-
if(HuffmanEncoding.method1027(Class59.anInt1388) && ChatBox.inputMessage.length() < 10) {
1423-
ChatBox.inputMessage = ChatBox.inputMessage + (char) Class59.anInt1388;
1424-
ChatBox.redrawChatbox = true;
1425-
}
1426-
if(ItemDefinition.anInt2854 == 84) {
1427-
if(ChatBox.inputMessage.length() > 0) {
1428-
int inputValue = 0;
1429-
try {
1430-
inputValue = Integer.parseInt(ChatBox.inputMessage);
1431-
} catch(Exception _ex) {
1432-
/* empty */
1433-
}
1434-
1435-
OutgoingPackets.sendMessage(new SubmitChatboxWidgetNumericInputOutboundMessage(inputValue));
1436-
}
1437-
ChatBox.redrawChatbox = true;
1438-
ChatBox.inputType = 0;
1439-
}
1440-
} else if(ChatBox.inputType == 2) {
1441-
if(ItemDefinition.anInt2854 == 85 && ChatBox.inputMessage.length() > 0) {
1442-
ChatBox.inputMessage = ChatBox.inputMessage.substring(0, -1 + ChatBox.inputMessage.length());
1443-
ChatBox.redrawChatbox = true;
1444-
}
1445-
if((Class40_Sub5_Sub15.method735(Class59.anInt1388) || Class59.anInt1388 == 32) && ChatBox.inputMessage.length() < 12) {
1446-
ChatBox.inputMessage = ChatBox.inputMessage + (char) Class59.anInt1388;
1447-
ChatBox.redrawChatbox = true;
1448-
}
1449-
if(ItemDefinition.anInt2854 == 84) {
1450-
if(ChatBox.inputMessage.length() > 0) {
1451-
long name = RSString.nameToLong(ChatBox.inputMessage);
1452-
1453-
OutgoingPackets.sendMessage(new SubmitChatboxWidgetNameInputOutboundMessage(name));
1454-
}
1455-
ChatBox.inputType = 0;
1456-
ChatBox.redrawChatbox = true;
1457-
}
1458-
} else if(ChatBox.inputType == 3) {
1459-
if(ItemDefinition.anInt2854 == 85 && ChatBox.inputMessage.length() > 0) {
1460-
ChatBox.inputMessage = ChatBox.inputMessage.substring(0, ChatBox.inputMessage.length() - 10);
1461-
ChatBox.redrawChatbox = true;
1462-
}
1463-
if(Player.method793(Class59.anInt1388) && ChatBox.inputMessage.length() < 40) {
1464-
ChatBox.inputMessage = ChatBox.inputMessage + (char) Class59.anInt1388;
1465-
ChatBox.redrawChatbox = true;
1466-
}
1467-
} else if(GameInterface.chatboxInterfaceId == -1 && GameInterface.fullscreenInterfaceId == -1) {
1468-
if(ItemDefinition.anInt2854 == 85 && ChatBox.chatboxInput.length() > 0) {
1469-
ChatBox.chatboxInput = ChatBox.chatboxInput.substring(0, ChatBox.chatboxInput.length() - 1);
1470-
ChatBox.redrawChatbox = true;
1471-
}
1472-
if(Player.method793(Class59.anInt1388) && ChatBox.chatboxInput.length() < 80) {
1473-
ChatBox.chatboxInput = ChatBox.chatboxInput + (char) Class59.anInt1388;
1474-
ChatBox.redrawChatbox = true;
1475-
}
1476-
if(ItemDefinition.anInt2854 == 84 && ChatBox.chatboxInput.length() > 0) {
1477-
if(InteractiveObject.playerRights > 1) {
1478-
if(ChatBox.chatboxInput.equals(English.commandClientDrop))
1479-
Class59.dropClient();
1480-
if(ChatBox.chatboxInput.equals(English.commandFpson)) {
1481-
InteractiveObject.showFps = true;
1482-
ChatBox.inputType = 3;
1483-
}
1484-
if(ChatBox.chatboxInput.startsWith("::region")) {
1485-
for(int qq = 0; qq < 469; qq++) {
1486-
if(GameInterface.decodeGameInterface(qq)) {
1487-
GameInterface[] gameInterfaces = GameInterface.cachedInterfaces[qq];
1488-
for(int y = 0; gameInterfaces.length > y; y++) {
1489-
GameInterface gameInterface = gameInterfaces[y];
1490-
if(gameInterface.disabledText != null) {
1491-
String text = gameInterface.disabledText.toString().toLowerCase();
1492-
if(gameInterface.disabledText.toString().toLowerCase().contains("bank")) {
1493-
System.out.println(qq + " contains " + text);
1494-
}
1495-
}
1496-
}
1497-
}
1498-
}
1499-
}
1500-
1501-
if(ChatBox.chatboxInput.equals(Native.cmd_fpsoff))
1502-
InteractiveObject.showFps = false;
1503-
if(ChatBox.chatboxInput.equals(English.commandNoclip)) {
1504-
for(int i = 0; i < 4; i++) {
1505-
for(int i_9_ = 1; i_9_ < 103; i_9_++) {
1506-
for(int i_10_ = 1; i_10_ < 103; i_10_++)
1507-
Landscape.currentCollisionMap[i].clippingData[i_9_][i_10_] = 0;
1508-
}
1509-
}
1510-
}
1511-
if(ChatBox.chatboxInput.equals(English.commandErrorTest) && Main.modewhere == 2)
1512-
throw new RuntimeException();
1513-
if(ChatBox.chatboxInput.equals(Native.cmd_hiddenbuttontest))
1514-
PacketBuffer.hiddenButtonTest = true;
1515-
}
1516-
if(ChatBox.chatboxInput.startsWith(Native.cmd_prefix)) {
1517-
// remove the :: prefix
1518-
String command = ChatBox.chatboxInput.substring(2);
1519-
1520-
OutgoingPackets.sendMessage(new ChatCommandOutboundMessage(command));
1521-
} else {
1522-
ChatColorEffect chatColorEffect = ChatColorEffect.fromString(ChatBox.chatboxInput.toLowerCase());
1523-
1524-
if (chatColorEffect != null) {
1525-
ChatBox.chatboxInput = ChatBox.chatboxInput.substring(chatColorEffect.getPrefixLength());
1526-
}
1527-
1528-
ChatShapeEffect chatShapeEffect = ChatShapeEffect.fromString(ChatBox.chatboxInput.toLowerCase());
1529-
1530-
if (chatShapeEffect != null) {
1531-
ChatBox.chatboxInput = ChatBox.chatboxInput.substring(chatShapeEffect.getPrefixLength());
1532-
}
1533-
1534-
ChatBox.filterInput();
1535-
1536-
SendChatMessageOutboundMessage message = new SendChatMessageOutboundMessage(
1537-
chatColorEffect != null ? chatColorEffect : ChatColorEffect.YELLOW,
1538-
chatShapeEffect != null ? chatShapeEffect : ChatShapeEffect.NONE,
1539-
ChatBox.chatboxInput
1540-
);
1541-
1542-
OutgoingPackets.sendMessage(message);
1543-
1544-
// I guess resets from 'off' to... 'friends'? public?
1545-
if(ChatBox.publicChatMode == 2) {
1546-
redrawChatbox = true;
1547-
ChatBox.publicChatMode = 3;
1548-
1549-
OutgoingPackets.sendMessage(new SetChatOptionsOutboundMessage(
1550-
ChatBox.publicChatMode,
1551-
ChatBox.privateChatMode,
1552-
ChatBox.tradeMode
1553-
));
1554-
}
1555-
}
1556-
ChatBox.redrawChatbox = true;
1557-
ChatBox.chatboxInput = "";
1558-
}
1559-
}
1560-
}
1561-
1562-
}
1563-
1564-
private static char VALID_CHARACTERS[] = {' ', 'e', 't', 'a', 'o', 'i', 'h', 'n', 's', 'r', 'd', 'l', 'u', 'm', 'w',
1303+
private static char VALID_CHARACTERS[] = {' ', 'e', 't', 'a', 'o', 'i', 'h', 'n', 's', 'r', 'd', 'l', 'u', 'm', 'w',
15651304
'c', 'y', 'f', 'g', 'p', 'b', 'v', 'k', 'x', 'j', 'q', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8',
15661305
'9', ' ', '!', '?', '.', ',', ':', ';', '(', ')', '-', '&', '*', '\\', '\'', '@', '#', '+', '=', '\243',
15671306
'$', '%', '"', '[', ']'};

0 commit comments

Comments
 (0)