MCPcopy Create free account
hub / github.com/5zig/The-5zig-Mod / draw

Method draw

The 5zig Mod/src/eu/the5zig/mod/chat/gui/ChatLine.java:47–124  ·  view source on GitHub ↗
(int x, int y)

Source from the content-addressed store, hash-verified

45 }
46
47 @Override
48 public void draw(int x, int y) {
49 Gui gui = The5zigMod.getVars().getCurrentScreen();
50 if (gui == null) {
51 return;
52 }
53
54 String time = ChatColor.GRAY + Utils.convertToTimeWithMinutes(message.getTime());
55 int timeWidth = (int) (The5zigMod.getVars().getStringWidth(time) * STATUS_SCALE);
56
57 List<String> lines = The5zigMod.getVars().splitStringToWidth(message.toString(), getMaxMessageWidth());
58 int yy = 2;
59 for (int i = 0; i < lines.size(); i++) {
60 String line = lines.get(i);
61 int lineWidth = The5zigMod.getVars().getStringWidth(line);
62 int xOff = 0;
63 if (i + 1 == lines.size()) {
64 xOff += timeWidth;
65 }
66 if (message.getMessageType() == Message.MessageType.LEFT) {
67 The5zigMod.getVars().drawString(line, x + 2, y + yy);
68 if (xOff > 0)
69 Gui.drawScaledString(time, x + 2 + lineWidth + 6, y + yy + 3, STATUS_SCALE);
70 }
71 if (message.getMessageType() == Message.MessageType.RIGHT) {
72 if (gui instanceof GuiParty) {
73 if (xOff > 0) {
74 The5zigMod.getVars().drawString(line, gui.getWidth() - 122 - lineWidth - xOff - 6, y + yy);
75 Gui.drawScaledString(time, gui.getWidth() - 122 - timeWidth, y + yy + 3, STATUS_SCALE);
76 } else {
77 The5zigMod.getVars().drawString(line, gui.getWidth() - 122 - lineWidth, y + yy);
78 }
79 } else {
80 if (xOff > 0) {
81 The5zigMod.getVars().drawString(line, gui.getWidth() - 22 - lineWidth - xOff - 6, y + yy);
82 Gui.drawScaledString(time, gui.getWidth() - 22 - timeWidth, y + yy + 3, STATUS_SCALE);
83 } else {
84 The5zigMod.getVars().drawString(line, gui.getWidth() - 22 - lineWidth, y + yy);
85 }
86 }
87 }
88 yy += LINE_HEIGHT;
89 }
90
91 if (message.getMessageType() == Message.MessageType.RIGHT) {
92 Message lastMessage = null;
93 List<Message> messages = Lists.newArrayList(message.getConversation().getMessages());
94 for (Message conversationMessage : messages) {
95 if (conversationMessage.getMessageType() == Message.MessageType.RIGHT ||
96 (conversationMessage instanceof FileMessage && ((FileMessage) conversationMessage).getFileData().isOwn()))
97 lastMessage = conversationMessage;
98 }
99 if (lastMessage == null || !lastMessage.equals(message))
100 return;
101 String status;
102 switch (message.getConversation().getStatus()) {
103 case SENT:
104 status = I18n.translate("chat.status.sent");

Callers

nothing calls this directly

Calls 15

getVarsMethod · 0.95
getMaxMessageWidthMethod · 0.95
drawScaledStringMethod · 0.95
getWidthMethod · 0.95
translateMethod · 0.95
sizeMethod · 0.80
getMessageTypeMethod · 0.80
getMessagesMethod · 0.80
isOwnMethod · 0.80
getCurrentScreenMethod · 0.65
getStringWidthMethod · 0.65

Tested by

no test coverage detected