OOC sent by an admin will have a different color (#3117)

* Admin OOC is sent with a different color than regular OOC

- Also adds the OOC color to the database

* Command to set the color

* Ooc -> OOC

* Change default color to Red (`#ff0000`)

* Outdated namespace
This commit is contained in:
Leo
2021-02-14 11:59:56 -03:00
committed by GitHub
parent 54f48aa6a9
commit a3d0e3f6a7
17 changed files with 1324 additions and 30 deletions

View File

@@ -205,23 +205,21 @@ namespace Content.Client.Chat
messageText = string.Format(message.MessageWrap, messageText); messageText = string.Format(message.MessageWrap, messageText);
} }
switch (message.Channel) if (message.MessageColorOverride != Color.Transparent)
{ {
case ChatChannel.Server: color = message.MessageColorOverride;
color = Color.Orange; }
break; else
case ChatChannel.Radio: {
color = Color.Green; color = message.Channel switch
break; {
case ChatChannel.OOC: ChatChannel.Server => Color.Orange,
color = Color.LightSkyBlue; ChatChannel.Radio => Color.Green,
break; ChatChannel.OOC => Color.LightSkyBlue,
case ChatChannel.Dead: ChatChannel.Dead => Color.MediumPurple,
color = Color.MediumPurple; ChatChannel.AdminChat => Color.Red,
break; _ => color
case ChatChannel.AdminChat: };
color = Color.Red;
break;
} }
_currentChatBox?.AddLine(messageText, message.Channel, color); _currentChatBox?.AddLine(messageText, message.Channel, color);

View File

@@ -1,4 +1,6 @@
using Content.Shared.Chat; using Content.Shared.Chat;
using Robust.Shared.Log;
using Robust.Shared.Maths;
namespace Content.Client.Chat namespace Content.Client.Chat
{ {
@@ -25,6 +27,11 @@ namespace Content.Client.Chat
/// </summary> /// </summary>
public string MessageWrap { get; set; } public string MessageWrap { get; set; }
/// <summary>
/// The override color of the message
/// </summary>
public Color MessageColorOverride { get; set; }
/// <summary> /// <summary>
/// Constructor to copy a net message into stored client variety /// Constructor to copy a net message into stored client variety
/// </summary> /// </summary>
@@ -33,6 +40,7 @@ namespace Content.Client.Chat
Message = netMsg.Message; Message = netMsg.Message;
Channel = netMsg.Channel; Channel = netMsg.Channel;
MessageWrap = netMsg.MessageWrap; MessageWrap = netMsg.MessageWrap;
MessageColorOverride = netMsg.MessageColorOverride;
} }
} }
} }

View File

@@ -39,7 +39,7 @@ namespace Content.Client
public void SelectCharacter(int slot) public void SelectCharacter(int slot)
{ {
Preferences = new PlayerPreferences(Preferences.Characters, slot); Preferences = new PlayerPreferences(Preferences.Characters, slot, Preferences.AdminOOCColor);
var msg = _netManager.CreateNetMessage<MsgSelectCharacter>(); var msg = _netManager.CreateNetMessage<MsgSelectCharacter>();
msg.SelectedCharacterIndex = slot; msg.SelectedCharacterIndex = slot;
_netManager.ClientSendMessage(msg); _netManager.ClientSendMessage(msg);
@@ -48,7 +48,7 @@ namespace Content.Client
public void UpdateCharacter(ICharacterProfile profile, int slot) public void UpdateCharacter(ICharacterProfile profile, int slot)
{ {
var characters = new Dictionary<int, ICharacterProfile>(Preferences.Characters) {[slot] = profile}; var characters = new Dictionary<int, ICharacterProfile>(Preferences.Characters) {[slot] = profile};
Preferences = new PlayerPreferences(characters, Preferences.SelectedCharacterIndex); Preferences = new PlayerPreferences(characters, Preferences.SelectedCharacterIndex, Preferences.AdminOOCColor);
var msg = _netManager.CreateNetMessage<MsgUpdateCharacter>(); var msg = _netManager.CreateNetMessage<MsgUpdateCharacter>();
msg.Profile = profile; msg.Profile = profile;
msg.Slot = slot; msg.Slot = slot;
@@ -69,7 +69,7 @@ namespace Content.Client
var l = lowest.Value; var l = lowest.Value;
characters.Add(l, profile); characters.Add(l, profile);
Preferences = new PlayerPreferences(characters, Preferences.SelectedCharacterIndex); Preferences = new PlayerPreferences(characters, Preferences.SelectedCharacterIndex, Preferences.AdminOOCColor);
UpdateCharacter(profile, l); UpdateCharacter(profile, l);
} }
@@ -82,7 +82,7 @@ namespace Content.Client
public void DeleteCharacter(int slot) public void DeleteCharacter(int slot)
{ {
var characters = Preferences.Characters.Where(p => p.Key != slot); var characters = Preferences.Characters.Where(p => p.Key != slot);
Preferences = new PlayerPreferences(characters, Preferences.SelectedCharacterIndex); Preferences = new PlayerPreferences(characters, Preferences.SelectedCharacterIndex, Preferences.AdminOOCColor);
var msg = _netManager.CreateNetMessage<MsgDeleteCharacter>(); var msg = _netManager.CreateNetMessage<MsgDeleteCharacter>();
msg.Slot = slot; msg.Slot = slot;
_netManager.ClientSendMessage(msg); _netManager.ClientSendMessage(msg);

View File

@@ -0,0 +1,580 @@
// <auto-generated />
using System;
using System.Net;
using Content.Server.Database;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
namespace Content.Server.Database.Migrations.Postgres
{
[DbContext(typeof(PostgresServerDbContext))]
[Migration("20210211211033_AdminOOCColor")]
partial class AdminOOCColor
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.UseIdentityByDefaultColumns()
.HasAnnotation("Relational:MaxIdentifierLength", 63)
.HasAnnotation("ProductVersion", "5.0.0");
modelBuilder.Entity("Content.Server.Database.Admin", b =>
{
b.Property<Guid>("UserId")
.ValueGeneratedOnAdd()
.HasColumnType("uuid")
.HasColumnName("user_id");
b.Property<int?>("AdminRankId")
.HasColumnType("integer")
.HasColumnName("admin_rank_id");
b.Property<string>("Title")
.HasColumnType("text")
.HasColumnName("title");
b.HasKey("UserId");
b.HasIndex("AdminRankId");
b.ToTable("admin");
});
modelBuilder.Entity("Content.Server.Database.AdminFlag", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer")
.HasColumnName("admin_flag_id")
.UseIdentityByDefaultColumn();
b.Property<Guid>("AdminId")
.HasColumnType("uuid")
.HasColumnName("admin_id");
b.Property<string>("Flag")
.IsRequired()
.HasColumnType("text")
.HasColumnName("flag");
b.Property<bool>("Negative")
.HasColumnType("boolean")
.HasColumnName("negative");
b.HasKey("Id");
b.HasIndex("AdminId");
b.HasIndex("Flag", "AdminId")
.IsUnique();
b.ToTable("admin_flag");
});
modelBuilder.Entity("Content.Server.Database.AdminRank", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer")
.HasColumnName("admin_rank_id")
.UseIdentityByDefaultColumn();
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text")
.HasColumnName("name");
b.HasKey("Id");
b.ToTable("admin_rank");
});
modelBuilder.Entity("Content.Server.Database.AdminRankFlag", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer")
.HasColumnName("admin_rank_flag_id")
.UseIdentityByDefaultColumn();
b.Property<int>("AdminRankId")
.HasColumnType("integer")
.HasColumnName("admin_rank_id");
b.Property<string>("Flag")
.IsRequired()
.HasColumnType("text")
.HasColumnName("flag");
b.HasKey("Id");
b.HasIndex("AdminRankId");
b.HasIndex("Flag", "AdminRankId")
.IsUnique();
b.ToTable("admin_rank_flag");
});
modelBuilder.Entity("Content.Server.Database.Antag", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer")
.HasColumnName("antag_id")
.UseIdentityByDefaultColumn();
b.Property<string>("AntagName")
.IsRequired()
.HasColumnType("text")
.HasColumnName("antag_name");
b.Property<int>("ProfileId")
.HasColumnType("integer")
.HasColumnName("profile_id");
b.HasKey("Id");
b.HasIndex("ProfileId", "AntagName")
.IsUnique();
b.ToTable("antag");
});
modelBuilder.Entity("Content.Server.Database.AssignedUserId", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer")
.HasColumnName("assigned_user_id_id")
.UseIdentityByDefaultColumn();
b.Property<Guid>("UserId")
.HasColumnType("uuid")
.HasColumnName("user_id");
b.Property<string>("UserName")
.IsRequired()
.HasColumnType("text")
.HasColumnName("user_name");
b.HasKey("Id");
b.HasIndex("UserId")
.IsUnique();
b.HasIndex("UserName")
.IsUnique();
b.ToTable("assigned_user_id");
});
modelBuilder.Entity("Content.Server.Database.Job", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer")
.HasColumnName("job_id")
.UseIdentityByDefaultColumn();
b.Property<string>("JobName")
.IsRequired()
.HasColumnType("text")
.HasColumnName("job_name");
b.Property<int>("Priority")
.HasColumnType("integer")
.HasColumnName("priority");
b.Property<int>("ProfileId")
.HasColumnType("integer")
.HasColumnName("profile_id");
b.HasKey("Id");
b.HasIndex("ProfileId");
b.ToTable("job");
});
modelBuilder.Entity("Content.Server.Database.PostgresConnectionLog", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer")
.HasColumnName("connection_log_id")
.UseIdentityByDefaultColumn();
b.Property<IPAddress>("Address")
.IsRequired()
.HasColumnType("inet")
.HasColumnName("address");
b.Property<DateTime>("Time")
.HasColumnType("timestamp with time zone")
.HasColumnName("time");
b.Property<Guid>("UserId")
.HasColumnType("uuid")
.HasColumnName("user_id");
b.Property<string>("UserName")
.IsRequired()
.HasColumnType("text")
.HasColumnName("user_name");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("connection_log");
b.HasCheckConstraint("AddressNotIPv6MappedIPv4", "NOT inet '::ffff:0.0.0.0/96' >>= address");
});
modelBuilder.Entity("Content.Server.Database.PostgresPlayer", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer")
.HasColumnName("player_id")
.UseIdentityByDefaultColumn();
b.Property<DateTime>("FirstSeenTime")
.HasColumnType("timestamp with time zone")
.HasColumnName("first_seen_time");
b.Property<IPAddress>("LastSeenAddress")
.IsRequired()
.HasColumnType("inet")
.HasColumnName("last_seen_address");
b.Property<DateTime>("LastSeenTime")
.HasColumnType("timestamp with time zone")
.HasColumnName("last_seen_time");
b.Property<string>("LastSeenUserName")
.IsRequired()
.HasColumnType("text")
.HasColumnName("last_seen_user_name");
b.Property<Guid>("UserId")
.HasColumnType("uuid")
.HasColumnName("user_id");
b.HasKey("Id");
b.HasIndex("LastSeenUserName");
b.HasIndex("UserId")
.IsUnique();
b.ToTable("player");
b.HasCheckConstraint("LastSeenAddressNotIPv6MappedIPv4", "NOT inet '::ffff:0.0.0.0/96' >>= last_seen_address");
});
modelBuilder.Entity("Content.Server.Database.PostgresServerBan", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer")
.HasColumnName("server_ban_id")
.UseIdentityByDefaultColumn();
b.Property<ValueTuple<IPAddress, int>?>("Address")
.HasColumnType("inet")
.HasColumnName("address");
b.Property<DateTime>("BanTime")
.HasColumnType("timestamp with time zone")
.HasColumnName("ban_time");
b.Property<Guid?>("BanningAdmin")
.HasColumnType("uuid")
.HasColumnName("banning_admin");
b.Property<DateTime?>("ExpirationTime")
.HasColumnType("timestamp with time zone")
.HasColumnName("expiration_time");
b.Property<string>("Reason")
.IsRequired()
.HasColumnType("text")
.HasColumnName("reason");
b.Property<Guid?>("UserId")
.HasColumnType("uuid")
.HasColumnName("user_id");
b.HasKey("Id");
b.HasIndex("Address");
b.HasIndex("UserId");
b.ToTable("server_ban");
b.HasCheckConstraint("AddressNotIPv6MappedIPv4", "NOT inet '::ffff:0.0.0.0/96' >>= address");
b.HasCheckConstraint("HaveEitherAddressOrUserId", "address IS NOT NULL OR user_id IS NOT NULL");
});
modelBuilder.Entity("Content.Server.Database.PostgresServerUnban", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer")
.HasColumnName("unban_id")
.UseIdentityByDefaultColumn();
b.Property<int>("BanId")
.HasColumnType("integer")
.HasColumnName("ban_id");
b.Property<DateTime>("UnbanTime")
.HasColumnType("timestamp with time zone")
.HasColumnName("unban_time");
b.Property<Guid?>("UnbanningAdmin")
.HasColumnType("uuid")
.HasColumnName("unbanning_admin");
b.HasKey("Id");
b.HasIndex("BanId")
.IsUnique();
b.ToTable("server_unban");
});
modelBuilder.Entity("Content.Server.Database.Preference", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer")
.HasColumnName("preference_id")
.UseIdentityByDefaultColumn();
b.Property<string>("AdminOOCColor")
.IsRequired()
.HasColumnType("text")
.HasColumnName("admin_ooc_color");
b.Property<int>("SelectedCharacterSlot")
.HasColumnType("integer")
.HasColumnName("selected_character_slot");
b.Property<Guid>("UserId")
.HasColumnType("uuid")
.HasColumnName("user_id");
b.HasKey("Id");
b.HasIndex("UserId")
.IsUnique();
b.ToTable("preference");
});
modelBuilder.Entity("Content.Server.Database.Profile", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer")
.HasColumnName("profile_id")
.UseIdentityByDefaultColumn();
b.Property<int>("Age")
.HasColumnType("integer")
.HasColumnName("age");
b.Property<string>("Backpack")
.IsRequired()
.HasColumnType("text")
.HasColumnName("backpack");
b.Property<string>("CharacterName")
.IsRequired()
.HasColumnType("text")
.HasColumnName("char_name");
b.Property<string>("Clothing")
.IsRequired()
.HasColumnType("text")
.HasColumnName("clothing");
b.Property<string>("EyeColor")
.IsRequired()
.HasColumnType("text")
.HasColumnName("eye_color");
b.Property<string>("FacialHairColor")
.IsRequired()
.HasColumnType("text")
.HasColumnName("facial_hair_color");
b.Property<string>("FacialHairName")
.IsRequired()
.HasColumnType("text")
.HasColumnName("facial_hair_name");
b.Property<string>("Gender")
.IsRequired()
.HasColumnType("text")
.HasColumnName("gender");
b.Property<string>("HairColor")
.IsRequired()
.HasColumnType("text")
.HasColumnName("hair_color");
b.Property<string>("HairName")
.IsRequired()
.HasColumnType("text")
.HasColumnName("hair_name");
b.Property<int>("PreferenceId")
.HasColumnType("integer")
.HasColumnName("preference_id");
b.Property<int>("PreferenceUnavailable")
.HasColumnType("integer")
.HasColumnName("pref_unavailable");
b.Property<string>("Sex")
.IsRequired()
.HasColumnType("text")
.HasColumnName("sex");
b.Property<string>("SkinColor")
.IsRequired()
.HasColumnType("text")
.HasColumnName("skin_color");
b.Property<int>("Slot")
.HasColumnType("integer")
.HasColumnName("slot");
b.HasKey("Id");
b.HasIndex("PreferenceId");
b.HasIndex("Slot", "PreferenceId")
.IsUnique();
b.ToTable("profile");
});
modelBuilder.Entity("Content.Server.Database.Admin", b =>
{
b.HasOne("Content.Server.Database.AdminRank", "AdminRank")
.WithMany("Admins")
.HasForeignKey("AdminRankId")
.OnDelete(DeleteBehavior.SetNull);
b.Navigation("AdminRank");
});
modelBuilder.Entity("Content.Server.Database.AdminFlag", b =>
{
b.HasOne("Content.Server.Database.Admin", "Admin")
.WithMany("Flags")
.HasForeignKey("AdminId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Admin");
});
modelBuilder.Entity("Content.Server.Database.AdminRankFlag", b =>
{
b.HasOne("Content.Server.Database.AdminRank", "Rank")
.WithMany("Flags")
.HasForeignKey("AdminRankId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Rank");
});
modelBuilder.Entity("Content.Server.Database.Antag", b =>
{
b.HasOne("Content.Server.Database.Profile", "Profile")
.WithMany("Antags")
.HasForeignKey("ProfileId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Profile");
});
modelBuilder.Entity("Content.Server.Database.Job", b =>
{
b.HasOne("Content.Server.Database.Profile", "Profile")
.WithMany("Jobs")
.HasForeignKey("ProfileId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Profile");
});
modelBuilder.Entity("Content.Server.Database.PostgresServerUnban", b =>
{
b.HasOne("Content.Server.Database.PostgresServerBan", "Ban")
.WithOne("Unban")
.HasForeignKey("Content.Server.Database.PostgresServerUnban", "BanId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Ban");
});
modelBuilder.Entity("Content.Server.Database.Profile", b =>
{
b.HasOne("Content.Server.Database.Preference", "Preference")
.WithMany("Profiles")
.HasForeignKey("PreferenceId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Preference");
});
modelBuilder.Entity("Content.Server.Database.Admin", b =>
{
b.Navigation("Flags");
});
modelBuilder.Entity("Content.Server.Database.AdminRank", b =>
{
b.Navigation("Admins");
b.Navigation("Flags");
});
modelBuilder.Entity("Content.Server.Database.PostgresServerBan", b =>
{
b.Navigation("Unban");
});
modelBuilder.Entity("Content.Server.Database.Preference", b =>
{
b.Navigation("Profiles");
});
modelBuilder.Entity("Content.Server.Database.Profile", b =>
{
b.Navigation("Antags");
b.Navigation("Jobs");
});
#pragma warning restore 612, 618
}
}
}

View File

@@ -0,0 +1,24 @@
using Microsoft.EntityFrameworkCore.Migrations;
namespace Content.Server.Database.Migrations.Postgres
{
public partial class AdminOOCColor : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>(
name: "admin_ooc_color",
table: "preference",
type: "text",
nullable: false,
defaultValue: "#ff0000");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "admin_ooc_color",
table: "preference");
}
}
}

View File

@@ -358,6 +358,11 @@ namespace Content.Server.Database.Migrations.Postgres
.HasColumnName("preference_id") .HasColumnName("preference_id")
.UseIdentityByDefaultColumn(); .UseIdentityByDefaultColumn();
b.Property<string>("AdminOOCColor")
.IsRequired()
.HasColumnType("text")
.HasColumnName("admin_ooc_color");
b.Property<int>("SelectedCharacterSlot") b.Property<int>("SelectedCharacterSlot")
.HasColumnType("integer") .HasColumnType("integer")
.HasColumnName("selected_character_slot"); .HasColumnName("selected_character_slot");

View File

@@ -0,0 +1,547 @@
// <auto-generated />
using System;
using Content.Server.Database;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
namespace Content.Server.Database.Migrations.Sqlite
{
[DbContext(typeof(SqliteServerDbContext))]
[Migration("20210211211028_AdminOOCColor")]
partial class AdminOOCColor
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "5.0.0");
modelBuilder.Entity("Content.Server.Database.Admin", b =>
{
b.Property<Guid>("UserId")
.ValueGeneratedOnAdd()
.HasColumnType("TEXT")
.HasColumnName("user_id");
b.Property<int?>("AdminRankId")
.HasColumnType("INTEGER")
.HasColumnName("admin_rank_id");
b.Property<string>("Title")
.HasColumnType("TEXT")
.HasColumnName("title");
b.HasKey("UserId");
b.HasIndex("AdminRankId");
b.ToTable("admin");
});
modelBuilder.Entity("Content.Server.Database.AdminFlag", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER")
.HasColumnName("admin_flag_id");
b.Property<Guid>("AdminId")
.HasColumnType("TEXT")
.HasColumnName("admin_id");
b.Property<string>("Flag")
.IsRequired()
.HasColumnType("TEXT")
.HasColumnName("flag");
b.Property<bool>("Negative")
.HasColumnType("INTEGER")
.HasColumnName("negative");
b.HasKey("Id");
b.HasIndex("AdminId");
b.HasIndex("Flag", "AdminId")
.IsUnique();
b.ToTable("admin_flag");
});
modelBuilder.Entity("Content.Server.Database.AdminRank", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER")
.HasColumnName("admin_rank_id");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("TEXT")
.HasColumnName("name");
b.HasKey("Id");
b.ToTable("admin_rank");
});
modelBuilder.Entity("Content.Server.Database.AdminRankFlag", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER")
.HasColumnName("admin_rank_flag_id");
b.Property<int>("AdminRankId")
.HasColumnType("INTEGER")
.HasColumnName("admin_rank_id");
b.Property<string>("Flag")
.IsRequired()
.HasColumnType("TEXT")
.HasColumnName("flag");
b.HasKey("Id");
b.HasIndex("AdminRankId");
b.HasIndex("Flag", "AdminRankId")
.IsUnique();
b.ToTable("admin_rank_flag");
});
modelBuilder.Entity("Content.Server.Database.Antag", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER")
.HasColumnName("antag_id");
b.Property<string>("AntagName")
.IsRequired()
.HasColumnType("TEXT")
.HasColumnName("antag_name");
b.Property<int>("ProfileId")
.HasColumnType("INTEGER")
.HasColumnName("profile_id");
b.HasKey("Id");
b.HasIndex("ProfileId", "AntagName")
.IsUnique();
b.ToTable("antag");
});
modelBuilder.Entity("Content.Server.Database.AssignedUserId", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER")
.HasColumnName("assigned_user_id_id");
b.Property<Guid>("UserId")
.HasColumnType("TEXT")
.HasColumnName("user_id");
b.Property<string>("UserName")
.IsRequired()
.HasColumnType("TEXT")
.HasColumnName("user_name");
b.HasKey("Id");
b.HasIndex("UserId")
.IsUnique();
b.HasIndex("UserName")
.IsUnique();
b.ToTable("assigned_user_id");
});
modelBuilder.Entity("Content.Server.Database.Job", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER")
.HasColumnName("job_id");
b.Property<string>("JobName")
.IsRequired()
.HasColumnType("TEXT")
.HasColumnName("job_name");
b.Property<int>("Priority")
.HasColumnType("INTEGER")
.HasColumnName("priority");
b.Property<int>("ProfileId")
.HasColumnType("INTEGER")
.HasColumnName("profile_id");
b.HasKey("Id");
b.HasIndex("ProfileId");
b.ToTable("job");
});
modelBuilder.Entity("Content.Server.Database.Preference", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER")
.HasColumnName("preference_id");
b.Property<string>("AdminOOCColor")
.IsRequired()
.HasColumnType("TEXT")
.HasColumnName("admin_ooc_color");
b.Property<int>("SelectedCharacterSlot")
.HasColumnType("INTEGER")
.HasColumnName("selected_character_slot");
b.Property<Guid>("UserId")
.HasColumnType("TEXT")
.HasColumnName("user_id");
b.HasKey("Id");
b.HasIndex("UserId")
.IsUnique();
b.ToTable("preference");
});
modelBuilder.Entity("Content.Server.Database.Profile", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER")
.HasColumnName("profile_id");
b.Property<int>("Age")
.HasColumnType("INTEGER")
.HasColumnName("age");
b.Property<string>("Backpack")
.IsRequired()
.HasColumnType("TEXT")
.HasColumnName("backpack");
b.Property<string>("CharacterName")
.IsRequired()
.HasColumnType("TEXT")
.HasColumnName("char_name");
b.Property<string>("Clothing")
.IsRequired()
.HasColumnType("TEXT")
.HasColumnName("clothing");
b.Property<string>("EyeColor")
.IsRequired()
.HasColumnType("TEXT")
.HasColumnName("eye_color");
b.Property<string>("FacialHairColor")
.IsRequired()
.HasColumnType("TEXT")
.HasColumnName("facial_hair_color");
b.Property<string>("FacialHairName")
.IsRequired()
.HasColumnType("TEXT")
.HasColumnName("facial_hair_name");
b.Property<string>("Gender")
.IsRequired()
.HasColumnType("TEXT")
.HasColumnName("gender");
b.Property<string>("HairColor")
.IsRequired()
.HasColumnType("TEXT")
.HasColumnName("hair_color");
b.Property<string>("HairName")
.IsRequired()
.HasColumnType("TEXT")
.HasColumnName("hair_name");
b.Property<int>("PreferenceId")
.HasColumnType("INTEGER")
.HasColumnName("preference_id");
b.Property<int>("PreferenceUnavailable")
.HasColumnType("INTEGER")
.HasColumnName("pref_unavailable");
b.Property<string>("Sex")
.IsRequired()
.HasColumnType("TEXT")
.HasColumnName("sex");
b.Property<string>("SkinColor")
.IsRequired()
.HasColumnType("TEXT")
.HasColumnName("skin_color");
b.Property<int>("Slot")
.HasColumnType("INTEGER")
.HasColumnName("slot");
b.HasKey("Id");
b.HasIndex("PreferenceId");
b.HasIndex("Slot", "PreferenceId")
.IsUnique();
b.ToTable("profile");
});
modelBuilder.Entity("Content.Server.Database.SqliteConnectionLog", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER")
.HasColumnName("connection_log_id");
b.Property<string>("Address")
.IsRequired()
.HasColumnType("TEXT")
.HasColumnName("address");
b.Property<DateTime>("Time")
.HasColumnType("TEXT")
.HasColumnName("time");
b.Property<Guid>("UserId")
.HasColumnType("TEXT")
.HasColumnName("user_id");
b.Property<string>("UserName")
.IsRequired()
.HasColumnType("TEXT")
.HasColumnName("user_name");
b.HasKey("Id");
b.ToTable("connection_log");
});
modelBuilder.Entity("Content.Server.Database.SqlitePlayer", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER")
.HasColumnName("player_id");
b.Property<DateTime>("FirstSeenTime")
.HasColumnType("TEXT")
.HasColumnName("first_seen_time");
b.Property<string>("LastSeenAddress")
.IsRequired()
.HasColumnType("TEXT")
.HasColumnName("last_seen_address");
b.Property<DateTime>("LastSeenTime")
.HasColumnType("TEXT")
.HasColumnName("last_seen_time");
b.Property<string>("LastSeenUserName")
.IsRequired()
.HasColumnType("TEXT")
.HasColumnName("last_seen_user_name");
b.Property<Guid>("UserId")
.HasColumnType("TEXT")
.HasColumnName("user_id");
b.HasKey("Id");
b.HasIndex("LastSeenUserName");
b.ToTable("player");
});
modelBuilder.Entity("Content.Server.Database.SqliteServerBan", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER")
.HasColumnName("ban_id");
b.Property<string>("Address")
.HasColumnType("TEXT")
.HasColumnName("address");
b.Property<DateTime>("BanTime")
.HasColumnType("TEXT")
.HasColumnName("ban_time");
b.Property<Guid?>("BanningAdmin")
.HasColumnType("TEXT")
.HasColumnName("banning_admin");
b.Property<DateTime?>("ExpirationTime")
.HasColumnType("TEXT")
.HasColumnName("expiration_time");
b.Property<string>("Reason")
.IsRequired()
.HasColumnType("TEXT")
.HasColumnName("reason");
b.Property<Guid?>("UserId")
.HasColumnType("TEXT")
.HasColumnName("user_id");
b.HasKey("Id");
b.ToTable("ban");
});
modelBuilder.Entity("Content.Server.Database.SqliteServerUnban", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER")
.HasColumnName("unban_id");
b.Property<int>("BanId")
.HasColumnType("INTEGER")
.HasColumnName("ban_id");
b.Property<DateTime>("UnbanTime")
.HasColumnType("TEXT")
.HasColumnName("unban_time");
b.Property<Guid?>("UnbanningAdmin")
.HasColumnType("TEXT")
.HasColumnName("unbanning_admin");
b.HasKey("Id");
b.HasIndex("BanId")
.IsUnique();
b.ToTable("unban");
});
modelBuilder.Entity("Content.Server.Database.Admin", b =>
{
b.HasOne("Content.Server.Database.AdminRank", "AdminRank")
.WithMany("Admins")
.HasForeignKey("AdminRankId")
.OnDelete(DeleteBehavior.SetNull);
b.Navigation("AdminRank");
});
modelBuilder.Entity("Content.Server.Database.AdminFlag", b =>
{
b.HasOne("Content.Server.Database.Admin", "Admin")
.WithMany("Flags")
.HasForeignKey("AdminId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Admin");
});
modelBuilder.Entity("Content.Server.Database.AdminRankFlag", b =>
{
b.HasOne("Content.Server.Database.AdminRank", "Rank")
.WithMany("Flags")
.HasForeignKey("AdminRankId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Rank");
});
modelBuilder.Entity("Content.Server.Database.Antag", b =>
{
b.HasOne("Content.Server.Database.Profile", "Profile")
.WithMany("Antags")
.HasForeignKey("ProfileId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Profile");
});
modelBuilder.Entity("Content.Server.Database.Job", b =>
{
b.HasOne("Content.Server.Database.Profile", "Profile")
.WithMany("Jobs")
.HasForeignKey("ProfileId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Profile");
});
modelBuilder.Entity("Content.Server.Database.Profile", b =>
{
b.HasOne("Content.Server.Database.Preference", "Preference")
.WithMany("Profiles")
.HasForeignKey("PreferenceId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Preference");
});
modelBuilder.Entity("Content.Server.Database.SqliteServerUnban", b =>
{
b.HasOne("Content.Server.Database.SqliteServerBan", "Ban")
.WithOne("Unban")
.HasForeignKey("Content.Server.Database.SqliteServerUnban", "BanId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Ban");
});
modelBuilder.Entity("Content.Server.Database.Admin", b =>
{
b.Navigation("Flags");
});
modelBuilder.Entity("Content.Server.Database.AdminRank", b =>
{
b.Navigation("Admins");
b.Navigation("Flags");
});
modelBuilder.Entity("Content.Server.Database.Preference", b =>
{
b.Navigation("Profiles");
});
modelBuilder.Entity("Content.Server.Database.Profile", b =>
{
b.Navigation("Antags");
b.Navigation("Jobs");
});
modelBuilder.Entity("Content.Server.Database.SqliteServerBan", b =>
{
b.Navigation("Unban");
});
#pragma warning restore 612, 618
}
}
}

View File

@@ -0,0 +1,24 @@
using Microsoft.EntityFrameworkCore.Migrations;
namespace Content.Server.Database.Migrations.Sqlite
{
public partial class AdminOOCColor : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>(
name: "admin_ooc_color",
table: "preference",
type: "text",
nullable: false,
defaultValue: "#ff0000");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "admin_ooc_color",
table: "preference");
}
}
}

View File

@@ -196,6 +196,11 @@ namespace Content.Server.Database.Migrations.Sqlite
.HasColumnType("INTEGER") .HasColumnType("INTEGER")
.HasColumnName("preference_id"); .HasColumnName("preference_id");
b.Property<string>("AdminOOCColor")
.IsRequired()
.HasColumnType("TEXT")
.HasColumnName("admin_ooc_color");
b.Property<int>("SelectedCharacterSlot") b.Property<int>("SelectedCharacterSlot")
.HasColumnType("INTEGER") .HasColumnType("INTEGER")
.HasColumnName("selected_character_slot"); .HasColumnName("selected_character_slot");

View File

@@ -80,6 +80,7 @@ namespace Content.Server.Database
[Column("preference_id")] public int Id { get; set; } [Column("preference_id")] public int Id { get; set; }
[Column("user_id")] public Guid UserId { get; set; } [Column("user_id")] public Guid UserId { get; set; }
[Column("selected_character_slot")] public int SelectedCharacterSlot { get; set; } [Column("selected_character_slot")] public int SelectedCharacterSlot { get; set; }
[Column("admin_ooc_color")] public string AdminOOCColor { get; set; } = null!;
public List<Profile> Profiles { get; } = new(); public List<Profile> Profiles { get; } = new();
} }

View File

@@ -0,0 +1,53 @@
#nullable enable
using Content.Server.Database;
using Content.Server.Interfaces;
using Content.Shared.Administration;
using Robust.Server.Player;
using Robust.Shared.Console;
using Robust.Shared.IoC;
using Robust.Shared.Localization;
using Robust.Shared.Maths;
namespace Content.Server.Administration.Commands
{
[AdminCommand(AdminFlags.Admin)]
internal class SetAdminOOC : IConsoleCommand
{
public string Command => "setadminooc";
public string Description => Loc.GetString($"Sets the color of your OOC messages. Color must be in hex format, example: {Command} #c43b23");
public string Help => Loc.GetString($"Usage: {Command} <color>");
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
if (!(shell.Player is IPlayerSession))
{
shell.WriteError(Loc.GetString("Only players can use this command"));
return;
}
if (args.Length < 1)
return;
var colorArg = string.Join(" ", args).Trim();
if (string.IsNullOrEmpty(colorArg))
return;
var color = Color.TryFromHex(colorArg);
if (!color.HasValue)
{
shell.WriteError(Loc.GetString("Invalid color hex!"));
return;
}
var userId = shell.Player.UserId;
// Save the DB
var dbMan = IoCManager.Resolve<IServerDbManager>();
dbMan.SaveAdminOOCColorAsync(userId, color.Value);
// Update the cached preference
var prefManager = IoCManager.Resolve<IServerPreferencesManager>();
var prefs = prefManager.GetPreferences(userId);
prefs.AdminOOCColor = color.Value;
}
}
}

View File

@@ -8,6 +8,7 @@ using Content.Server.GameObjects.Components.Observer;
using Content.Server.GameObjects.EntitySystems; using Content.Server.GameObjects.EntitySystems;
using Content.Server.Interfaces; using Content.Server.Interfaces;
using Content.Server.Interfaces.Chat; using Content.Server.Interfaces.Chat;
using Content.Shared.Administration;
using Content.Shared.Chat; using Content.Shared.Chat;
using Content.Shared.GameObjects.Components.Inventory; using Content.Shared.GameObjects.Components.Inventory;
using Content.Shared.GameObjects.EntitySystems.ActionBlocker; using Content.Shared.GameObjects.EntitySystems.ActionBlocker;
@@ -47,6 +48,7 @@ namespace Content.Server.Chat
[Dependency] private readonly IPlayerManager _playerManager = default!; [Dependency] private readonly IPlayerManager _playerManager = default!;
[Dependency] private readonly IMoMMILink _mommiLink = default!; [Dependency] private readonly IMoMMILink _mommiLink = default!;
[Dependency] private readonly IAdminManager _adminManager = default!; [Dependency] private readonly IAdminManager _adminManager = default!;
[Dependency] private readonly IServerPreferencesManager _preferencesManager = default!;
public void Initialize() public void Initialize()
{ {
@@ -187,7 +189,7 @@ namespace Content.Server.Chat
public void SendOOC(IPlayerSession player, string message) public void SendOOC(IPlayerSession player, string message)
{ {
// Check if message exceeds the character limi // Check if message exceeds the character limit
if (message.Length > MaxMessageLength) if (message.Length > MaxMessageLength)
{ {
DispatchServerMessage(player, Loc.GetString(MaxLengthExceededMessage, MaxMessageLength)); DispatchServerMessage(player, Loc.GetString(MaxLengthExceededMessage, MaxMessageLength));
@@ -198,6 +200,12 @@ namespace Content.Server.Chat
msg.Channel = ChatChannel.OOC; msg.Channel = ChatChannel.OOC;
msg.Message = message; msg.Message = message;
msg.MessageWrap = $"OOC: {player.Name}: {{0}}"; msg.MessageWrap = $"OOC: {player.Name}: {{0}}";
if (_adminManager.HasAdminFlag(player, AdminFlags.Admin))
{
var prefs = _preferencesManager.GetPreferences((player.UserId));
msg.MessageColorOverride = prefs.AdminOOCColor;
}
//TODO: player.Name color, this will need to change the structure of the MsgChatMessage
_netManager.ServerSendToAll(msg); _netManager.ServerSendToAll(msg);
_mommiLink.SendOOCMessage(player.Name, message); _mommiLink.SendOOCMessage(player.Name, message);

View File

@@ -15,6 +15,8 @@ namespace Content.Server.Database
{ {
public abstract class ServerDbBase public abstract class ServerDbBase
{ {
#region Preferences
public async Task<PlayerPreferences?> GetPlayerPreferencesAsync(NetUserId userId) public async Task<PlayerPreferences?> GetPlayerPreferencesAsync(NetUserId userId)
{ {
await using var db = await GetDb(); await using var db = await GetDb();
@@ -34,7 +36,7 @@ namespace Content.Server.Database
profiles[profile.Slot] = ConvertProfiles(profile); profiles[profile.Slot] = ConvertProfiles(profile);
} }
return new PlayerPreferences(profiles, prefs.SelectedCharacterSlot); return new PlayerPreferences(profiles, prefs.SelectedCharacterSlot, Color.FromHex(prefs.AdminOOCColor));
} }
public async Task SaveSelectedCharacterIndexAsync(NetUserId userId, int index) public async Task SaveSelectedCharacterIndexAsync(NetUserId userId, int index)
@@ -99,7 +101,8 @@ namespace Content.Server.Database
var prefs = new Preference var prefs = new Preference
{ {
UserId = userId.UserId, UserId = userId.UserId,
SelectedCharacterSlot = 0 SelectedCharacterSlot = 0,
AdminOOCColor = Color.Red.ToHex()
}; };
prefs.Profiles.Add(profile); prefs.Profiles.Add(profile);
@@ -108,7 +111,7 @@ namespace Content.Server.Database
await db.DbContext.SaveChangesAsync(); await db.DbContext.SaveChangesAsync();
return new PlayerPreferences(new[] {new KeyValuePair<int, ICharacterProfile>(0, defaultProfile)}, 0); return new PlayerPreferences(new[] {new KeyValuePair<int, ICharacterProfile>(0, defaultProfile)}, 0, Color.FromHex(prefs.AdminOOCColor));
} }
public async Task DeleteSlotAndSetSelectedIndex(NetUserId userId, int deleteSlot, int newSlot) public async Task DeleteSlotAndSetSelectedIndex(NetUserId userId, int deleteSlot, int newSlot)
@@ -121,6 +124,19 @@ namespace Content.Server.Database
await db.DbContext.SaveChangesAsync(); await db.DbContext.SaveChangesAsync();
} }
public async Task SaveAdminOOCColorAsync(NetUserId userId, Color color)
{
await using var db = await GetDb();
var prefs = await db.DbContext
.Preference
.Include(p => p.Profiles)
.SingleAsync(p => p.UserId == userId.UserId);
prefs.AdminOOCColor = color.ToHex();
await db.DbContext.SaveChangesAsync();
}
private static async Task SetSelectedCharacterSlotAsync(NetUserId userId, int newSlot, ServerDbContext db) private static async Task SetSelectedCharacterSlotAsync(NetUserId userId, int newSlot, ServerDbContext db)
{ {
var prefs = await db.Preference.SingleAsync(p => p.UserId == userId.UserId); var prefs = await db.Preference.SingleAsync(p => p.UserId == userId.UserId);
@@ -203,6 +219,7 @@ namespace Content.Server.Database
return entity; return entity;
} }
#endregion
public async Task<NetUserId?> GetAssignedUserIdAsync(string name) public async Task<NetUserId?> GetAssignedUserIdAsync(string name)
{ {

View File

@@ -14,6 +14,7 @@ using Robust.Shared.Configuration;
using Robust.Shared.ContentPack; using Robust.Shared.ContentPack;
using Robust.Shared.IoC; using Robust.Shared.IoC;
using Robust.Shared.Log; using Robust.Shared.Log;
using Robust.Shared.Maths;
using Robust.Shared.Network; using Robust.Shared.Network;
using LogLevel = Robust.Shared.Log.LogLevel; using LogLevel = Robust.Shared.Log.LogLevel;
using MSLogLevel = Microsoft.Extensions.Logging.LogLevel; using MSLogLevel = Microsoft.Extensions.Logging.LogLevel;
@@ -32,6 +33,8 @@ namespace Content.Server.Database
Task SaveCharacterSlotAsync(NetUserId userId, ICharacterProfile? profile, int slot); Task SaveCharacterSlotAsync(NetUserId userId, ICharacterProfile? profile, int slot);
Task SaveAdminOOCColorAsync(NetUserId userId, Color color);
// Single method for two operations for transaction. // Single method for two operations for transaction.
Task DeleteSlotAndSetSelectedIndex(NetUserId userId, int deleteSlot, int newSlot); Task DeleteSlotAndSetSelectedIndex(NetUserId userId, int deleteSlot, int newSlot);
Task<PlayerPreferences?> GetPlayerPreferencesAsync(NetUserId userId); Task<PlayerPreferences?> GetPlayerPreferencesAsync(NetUserId userId);
@@ -151,6 +154,11 @@ namespace Content.Server.Database
return _db.DeleteSlotAndSetSelectedIndex(userId, deleteSlot, newSlot); return _db.DeleteSlotAndSetSelectedIndex(userId, deleteSlot, newSlot);
} }
public Task SaveAdminOOCColorAsync(NetUserId userId, Color color)
{
return _db.SaveAdminOOCColorAsync(userId, color);
}
public Task<PlayerPreferences?> GetPlayerPreferencesAsync(NetUserId userId) public Task<PlayerPreferences?> GetPlayerPreferencesAsync(NetUserId userId)
{ {
return _db.GetPlayerPreferencesAsync(userId); return _db.GetPlayerPreferencesAsync(userId);

View File

@@ -12,6 +12,7 @@ using Robust.Server.Player;
using Robust.Shared.Configuration; using Robust.Shared.Configuration;
using Robust.Shared.IoC; using Robust.Shared.IoC;
using Robust.Shared.Log; using Robust.Shared.Log;
using Robust.Shared.Maths;
using Robust.Shared.Network; using Robust.Shared.Network;
using Robust.Shared.Prototypes; using Robust.Shared.Prototypes;
@@ -72,7 +73,7 @@ namespace Content.Server.Preferences
return; return;
} }
prefsData.Prefs = new PlayerPreferences(curPrefs.Characters, index); prefsData.Prefs = new PlayerPreferences(curPrefs.Characters, index, curPrefs.AdminOOCColor);
if (ShouldStorePrefs(message.MsgChannel.AuthType)) if (ShouldStorePrefs(message.MsgChannel.AuthType))
{ {
@@ -111,7 +112,7 @@ namespace Content.Server.Preferences
[slot] = HumanoidCharacterProfile.EnsureValid((HumanoidCharacterProfile) profile, _protos) [slot] = HumanoidCharacterProfile.EnsureValid((HumanoidCharacterProfile) profile, _protos)
}; };
prefsData.Prefs = new PlayerPreferences(profiles, slot); prefsData.Prefs = new PlayerPreferences(profiles, slot, curPrefs.AdminOOCColor);
if (ShouldStorePrefs(message.MsgChannel.AuthType)) if (ShouldStorePrefs(message.MsgChannel.AuthType))
{ {
@@ -156,7 +157,7 @@ namespace Content.Server.Preferences
var arr = new Dictionary<int, ICharacterProfile>(curPrefs.Characters); var arr = new Dictionary<int, ICharacterProfile>(curPrefs.Characters);
arr.Remove(slot); arr.Remove(slot);
prefsData.Prefs = new PlayerPreferences(arr, nextSlot ?? curPrefs.SelectedCharacterIndex); prefsData.Prefs = new PlayerPreferences(arr, nextSlot ?? curPrefs.SelectedCharacterIndex, curPrefs.AdminOOCColor);
if (ShouldStorePrefs(message.MsgChannel.AuthType)) if (ShouldStorePrefs(message.MsgChannel.AuthType))
{ {
@@ -181,7 +182,7 @@ namespace Content.Server.Preferences
PrefsLoaded = Task.CompletedTask, PrefsLoaded = Task.CompletedTask,
Prefs = new PlayerPreferences( Prefs = new PlayerPreferences(
new[] {new KeyValuePair<int, ICharacterProfile>(0, HumanoidCharacterProfile.Default())}, new[] {new KeyValuePair<int, ICharacterProfile>(0, HumanoidCharacterProfile.Default())},
0) 0, Color.Transparent)
}; };
_cachedPlayerPrefs[session.UserId] = prefsData; _cachedPlayerPrefs[session.UserId] = prefsData;
@@ -279,7 +280,7 @@ namespace Content.Server.Preferences
} }
return new KeyValuePair<int, ICharacterProfile>(p.Key, newProf); return new KeyValuePair<int, ICharacterProfile>(p.Key, newProf);
}), prefs.SelectedCharacterIndex); }), prefs.SelectedCharacterIndex, prefs.AdminOOCColor);
} }
public IEnumerable<KeyValuePair<NetUserId, ICharacterProfile>> GetSelectedProfilesForPlayers( public IEnumerable<KeyValuePair<NetUserId, ICharacterProfile>> GetSelectedProfilesForPlayers(

View File

@@ -1,5 +1,7 @@
using JetBrains.Annotations;
using Lidgren.Network; using Lidgren.Network;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.Maths;
using Robust.Shared.Network; using Robust.Shared.Network;
namespace Content.Shared.Chat namespace Content.Shared.Chat
@@ -7,6 +9,7 @@ namespace Content.Shared.Chat
/// <summary> /// <summary>
/// Sent from server to client to notify the client about a new chat message. /// Sent from server to client to notify the client about a new chat message.
/// </summary> /// </summary>
[UsedImplicitly]
public sealed class MsgChatMessage : NetMessage public sealed class MsgChatMessage : NetMessage
{ {
#region REQUIRED #region REQUIRED
@@ -38,6 +41,12 @@ namespace Content.Shared.Chat
/// </summary> /// </summary>
public EntityUid SenderEntity { get; set; } public EntityUid SenderEntity { get; set; }
/// <summary>
/// The override color of the message
/// </summary>
public Color MessageColorOverride { get; set; } = Color.Transparent;
public override void ReadFromBuffer(NetIncomingMessage buffer) public override void ReadFromBuffer(NetIncomingMessage buffer)
{ {
Channel = (ChatChannel) buffer.ReadInt16(); Channel = (ChatChannel) buffer.ReadInt16();
@@ -53,6 +62,7 @@ namespace Content.Shared.Chat
SenderEntity = buffer.ReadEntityUid(); SenderEntity = buffer.ReadEntityUid();
break; break;
} }
MessageColorOverride = buffer.ReadColor();
} }
public override void WriteToBuffer(NetOutgoingMessage buffer) public override void WriteToBuffer(NetOutgoingMessage buffer)
@@ -70,6 +80,7 @@ namespace Content.Shared.Chat
buffer.Write(SenderEntity); buffer.Write(SenderEntity);
break; break;
} }
buffer.Write(MessageColorOverride);
} }
} }
} }

View File

@@ -1,5 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using Robust.Shared.Maths;
using Robust.Shared.Serialization; using Robust.Shared.Serialization;
using Robust.Shared.Utility; using Robust.Shared.Utility;
@@ -15,10 +16,11 @@ namespace Content.Shared.Preferences
{ {
private Dictionary<int, ICharacterProfile> _characters; private Dictionary<int, ICharacterProfile> _characters;
public PlayerPreferences(IEnumerable<KeyValuePair<int, ICharacterProfile>> characters, int selectedCharacterIndex) public PlayerPreferences(IEnumerable<KeyValuePair<int, ICharacterProfile>> characters, int selectedCharacterIndex, Color adminOOCColor)
{ {
_characters = new Dictionary<int, ICharacterProfile>(characters); _characters = new Dictionary<int, ICharacterProfile>(characters);
SelectedCharacterIndex = selectedCharacterIndex; SelectedCharacterIndex = selectedCharacterIndex;
AdminOOCColor = adminOOCColor;
} }
/// <summary> /// <summary>
@@ -41,6 +43,8 @@ namespace Content.Shared.Preferences
/// </summary> /// </summary>
public ICharacterProfile SelectedCharacter => Characters[SelectedCharacterIndex]; public ICharacterProfile SelectedCharacter => Characters[SelectedCharacterIndex];
public Color AdminOOCColor { get; set; }
public int FirstEmptySlot() public int FirstEmptySlot()
{ {
var firstEmpty = IndexOfCharacter(null); var firstEmpty = IndexOfCharacter(null);