Customizable chat formatting (Closes #5387)

This commit is contained in:
Anuken
2021-10-10 12:37:07 -04:00
parent 919db8cc76
commit c60bd6f0dc
4 changed files with 36 additions and 45 deletions
@@ -9,7 +9,6 @@ import arc.util.*;
import arc.util.pooling.*;
import mindustry.annotations.Annotations.*;
import mindustry.content.*;
import mindustry.core.*;
import mindustry.entities.units.*;
import mindustry.game.EventType.*;
import mindustry.game.*;
@@ -310,10 +309,15 @@ abstract class PlayerComp implements UnitController, Entityc, Syncc, Timerc, Dra
Draw.z(z);
}
/** @return name with a markup color prefix */
String coloredName(){
return "[#" + color.toString().toUpperCase() + "]" + name;
}
void sendMessage(String text){
if(isLocal()){
if(ui != null){
ui.chatfrag.addMessage(text, null);
ui.chatfrag.addMessage(text);
}
}else{
Call.sendMessage(con, text, null, null);
@@ -321,16 +325,16 @@ abstract class PlayerComp implements UnitController, Entityc, Syncc, Timerc, Dra
}
void sendMessage(String text, Player from){
sendMessage(text, from, NetClient.colorizeName(from.id(), from.name));
sendMessage(text, from, null);
}
void sendMessage(String text, Player from, String fromName){
void sendMessage(String text, Player from, String unformatted){
if(isLocal()){
if(ui != null){
ui.chatfrag.addMessage(text, fromName);
ui.chatfrag.addMessage(text);
}
}else{
Call.sendMessage(con, text, fromName, from);
Call.sendMessage(con, text, unformatted, from);
}
}