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:
@@ -15,6 +15,8 @@ namespace Content.Server.Database
|
||||
{
|
||||
public abstract class ServerDbBase
|
||||
{
|
||||
|
||||
#region Preferences
|
||||
public async Task<PlayerPreferences?> GetPlayerPreferencesAsync(NetUserId userId)
|
||||
{
|
||||
await using var db = await GetDb();
|
||||
@@ -34,7 +36,7 @@ namespace Content.Server.Database
|
||||
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)
|
||||
@@ -99,7 +101,8 @@ namespace Content.Server.Database
|
||||
var prefs = new Preference
|
||||
{
|
||||
UserId = userId.UserId,
|
||||
SelectedCharacterSlot = 0
|
||||
SelectedCharacterSlot = 0,
|
||||
AdminOOCColor = Color.Red.ToHex()
|
||||
};
|
||||
|
||||
prefs.Profiles.Add(profile);
|
||||
@@ -108,7 +111,7 @@ namespace Content.Server.Database
|
||||
|
||||
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)
|
||||
@@ -121,6 +124,19 @@ namespace Content.Server.Database
|
||||
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)
|
||||
{
|
||||
var prefs = await db.Preference.SingleAsync(p => p.UserId == userId.UserId);
|
||||
@@ -203,6 +219,7 @@ namespace Content.Server.Database
|
||||
|
||||
return entity;
|
||||
}
|
||||
#endregion
|
||||
|
||||
public async Task<NetUserId?> GetAssignedUserIdAsync(string name)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user