C#:
using UnityEngine;
using System.Text;
using System.Collections.Generic;
using Newtonsoft.Json;
using Oxide.Core.Plugins;
using System.Linq;
using Oxide.Core.Configuration;
using Oxide.Core;
using Oxide.Plugins.TeamGUIEx;
using System.Reflection;
using System;
using Network;
using Oxide.Game.Rust.Cui;
using System.IO;
using System.Runtime.Serialization;
using System.Drawing.Drawing2D;
using System.Text.RegularExpressions;
using Facepunch;
namespace Oxide.Plugins
{
[Info( "TeamGUI", "oxide-russia.ru", "2.0.3", ResourceId = 169 )]
[Description( "" )]
class TeamGUI : RustPlugin
{
public static TeamGUI _plugin;
public JSONFile<ConfigData> _settingsFile;
public ConfigData Settings { get { return _settingsFile.Instance; } }
public PlayerDataController<TeamGUIPlayerData> PlayerData;
public Timer HealthUpdateTimer;
private readonly Regex avatarFilter = new Regex( @"<avatarFull><!\[CDATA\[(.*)\]\]></avatarFull>" );
#region UI
public Dictionary<int, RustUIElement<ImageData>> IconToIndex = new Dictionary<int, RustUIElement<ImageData>>();
public void BuildUI()
{
for ( int i = 0; i < 8; i++ )
{
int index = i;
var icon = ImageData.CreateRawImage( GetTeamIconPlacement( index ), null, null );
icon.Layer = "Under";
icon.AddConditional( ( player, data ) =>
{
GetIconConditional( player, data, index );
} );
var healthBar = ImageButton.CreateElement( UIPlacement.MiddleCenter_Pixels( 75, 75, 0, 0 ), icon, null );
healthBar.AddConditional( ( player, data ) =>
{
GetHealthBarConditional( player, data, index );
} );
healthBar.Settings.Callback = ( player ) =>
{
SendTeleportRequest( player, index );
};
IconToIndex.Add( index, icon );
}
}
public void RegisterImages()
{
AddImage( "http://i.imgur.com/pulQPKL.png", "naked_head_alive", 3 );
AddImage( "http://i.imgur.com/r6RnyZG.png", "naked_head_offline", 3 );
AddImage( "http://i.imgur.com/SjzJi3J.png", "no_health", 3 );
AddImage( "http://i.imgur.com/yGTVaxa.png", "1/10_health", 3 );
AddImage( "http://i.imgur.com/Rzav5dh.png", "2/10_health", 3 );
AddImage( "http://i.imgur.com/n9Eggpx.png", "3/10_health", 3 );
AddImage( "http://i.imgur.com/6M3KAtr.png", "4/10_health", 3 );
AddImage( "http://i.imgur.com/s4H7LNV.png", "5/10_health", 3 );
AddImage( "http://i.imgur.com/RYw5SmW.png", "6/10_health", 3 );
AddImage( "http://i.imgur.com/1sg1taT.png", "7/10_health", 3 );
AddImage( "http://i.imgur.com/MGwSlHQ.png", "8/10_health", 3 );
AddImage( "http://i.imgur.com/vBy7api.png", "9/10_health", 3 );
AddImage( "http://i.imgur.com/LIJPxsj.png", "full_health", 3 );
AddImage( "http://i.imgur.com/JlNBYmT.png", "wounded", 2 );
}
public void DestroyUI()
{
foreach ( var icon in IconToIndex )
{
icon.Value.HideAll();
}
}
#region UI Functions
#region Conditionals
public void GetIconConditional( BasePlayer player, ImageData data, int index )
{
if ( !permission.UserHasPermission( player.UserIDString, "teamgui.allow" ) || !PlayerData.Get( player ).ShowUI )
{
data.ShouldShow = false;
return;
}
var playerTeam = GetTeam( player );
if ( playerTeam == null )
{
data.ShouldShow = false;
return;
}
var onlineMembers = GetOnlineMembersInTeam( playerTeam.members, player.userID );
if ( onlineMembers.Count == 0 || onlineMembers.Count <= index )
{
data.ShouldShow = false;
Pool.FreeList( ref onlineMembers );
return;
}
var member = onlineMembers[ index ];
Pool.FreeList( ref onlineMembers );
data.PNG = GetPlayerProfilePicture( member.UserIDString );
}
public void GetHealthBarConditional( BasePlayer player, ImageButton data, int index )
{
if ( !permission.UserHasPermission( player.UserIDString, "teamgui.allow" ) || !PlayerData.Get( player ).ShowUI )
{
data.ShouldShow = false;
return;
}
var playerTeam = GetTeam( player );
if ( playerTeam == null )
{
data.ShouldShow = false;
return;
}
var onlineMembers = GetOnlineMembersInTeam( playerTeam.members, player.userID );
if ( onlineMembers.Count == 0 || onlineMembers.Count <= index )
{
Pool.FreeList( ref onlineMembers );
data.ShouldShow = false;
return;
}
var member = onlineMembers[ index ];
Pool.FreeList( ref onlineMembers );
if ( member.IsDead() )
{
data.PNG = GetImage( "no_health", 3 );
}
if ( member.IsWounded() )
{
data.PNG = GetImage( "wounded", 2 );
}
else
{
var memberData = PlayerData.Get( member );
memberData.ReassignHealthImageIndex( member );
data.PNG = _plugin.GetHealthBarImage( memberData.HealthImageIndex );
}
}
#endregion
#region Callbacks
public void SendTeleportRequest( BasePlayer player, int index )
{
var playerTeam = GetTeam( player );
if ( playerTeam == null )
{
return;
}
var onlineMembers = GetOnlineMembersInTeam( playerTeam.members, player.userID );
if ( onlineMembers.Count == 0 || onlineMembers.Count < index )
{
Pool.FreeList( ref onlineMembers );
return;
}
var member = onlineMembers[ index ];
Pool.FreeList( ref onlineMembers );
player.SendConsoleCommand( "chat.say", $"/tpr \"{member.displayName}\"" );
}
#endregion
#region Updating UI
private List<RustUIElement<ImageData>> IconsToRefresh = new List<RustUIElement<ImageData>>();
public void UpdateIcons()
{
foreach ( var team in RelationshipManager.Instance.teams.Values )
{
var onlineMembers = GetOnlineMembersInTeam( team.members );
if ( onlineMembers.Count == 0 )
{
Pool.FreeList( ref onlineMembers );
continue;
}
IconsToRefresh.Clear();
foreach ( var member in onlineMembers )
{
if ( ShouldUpdateUI( member ) )
{
var iconToRefresh = IconToIndex[ onlineMembers.IndexOf( member ) ];
IconsToRefresh.Add( iconToRefresh );
}
}
if ( IconsToRefresh.Count == 0 )
{
Pool.FreeList( ref onlineMembers );
continue;
}
foreach ( var member in onlineMembers )
{
foreach ( var icon in IconsToRefresh )
{
icon.Refresh( member );
}
}
Pool.FreeList( ref onlineMembers );
}
}
public void RefreshTeamGUIForTeam( List<ulong> members )
{
var onlineMembers = GetOnlineMembersInTeam( members );
if ( onlineMembers.Count == 0 )
{
Pool.FreeList( ref onlineMembers );
return;
}
foreach ( var member in onlineMembers )
{
foreach ( var icon in IconToIndex.Values )
{
icon.Refresh( member );
}
}
Pool.FreeList( ref onlineMembers );
}
public bool ShouldUpdateUI( BasePlayer player )
{
var playerData = PlayerData.Get( player );
if ( !HasImage( player.UserIDString, 5 ) && !playerData.ImageSettingUp )
{
playerData.ImageSettingUp = true;
if ( !HasImage( player.UserIDString, 0 ) )
{
_plugin.GetPlayerAvatar( player.UserIDString );
}
string profilePicture = GetImage( "naked_head_alive", 3 );
_plugin.timer.In( 10, () =>
{
profilePicture = GetPlayerProfilePicture( player.UserIDString );
} );
_plugin.timer.In( 10, () =>
{
playerData.ImageSettingUp = false;
var playerTeam = GetTeam( player );
if ( playerTeam != null )
{
RefreshTeamGUIForTeam( playerTeam.members );
}
} );
}
int oldHealthImageIndex = playerData.HealthImageIndex;
playerData.ReassignHealthImageIndex( player );
bool oldWounded = playerData.IsWounded;
playerData.IsWounded = player.IsWounded();
if ( oldHealthImageIndex != playerData.HealthImageIndex || oldWounded != playerData.IsWounded )
{
return true;
}
return false;
}
#endregion
#region Placement
public UIPlacement GetTeamIconPlacement( int index )
{
ConfigurableUIPlacement configPlacement = null;
if ( !_plugin.Settings.PlacementToIndex.TryGetValue( index, out configPlacement ) || configPlacement == null )
{
_plugin.PrintError( "Couldn't get placement for icon, make sure your config has 0, 1, 2, 3, 4, 5, 6, and 7, if any are missing it won't show!" );
return UIPlacement.MiddleCenter_Pixels( 0, 0, 0, 0 );
}
return UIPlacement.MiddleCenter_Pixels( configPlacement.xSize, configPlacement.ySize, configPlacement.xOffset, configPlacement.yOffset );
}
#endregion
#region Image Handling
public void GetPlayerAvatar( string userId )
{
if ( string.IsNullOrEmpty( userId ) || HasImage( userId, 0 ) )
{
return;
}
webrequest.Enqueue( $"http://steamcommunity.com/profiles/{userId}?xml=1", null, ( code, response ) =>
{
if ( response != null && code == 200 )
{
string avatar = avatarFilter.Match( response ).Groups[ 1 ].ToString();
if ( !string.IsNullOrEmpty( avatar ) )
AddImage( avatar, userId, 0 );
}
}, this );
}
public string GetHealthBarImage( int healthFraction )
{
switch ( healthFraction )
{
default:
case 0:
{
return GetImage( "no_health", 3 );
}
case 1:
{
return GetImage( "1/10_health", 3 );
}
case 2:
{
return GetImage( "2/10_health", 3 );
}
case 3:
{
return GetImage( "3/10_health", 3 );
}
case 4:
{
return GetImage( "4/10_health", 3 );
}
case 5:
{
return GetImage( "5/10_health", 3 );
}
case 6:
{
return GetImage( "6/10_health", 3 );
}
case 7:
{
return GetImage( "7/10_health", 3 );
}
case 8:
{
return GetImage( "8/10_health", 3 );
}
case 9:
{
return GetImage( "9/10_health", 3 );
}
case 10:
{
return GetImage( "full_health", 3 );
}
}
}
public static string GetPlayerProfilePicture( string userIDString )
{
if ( HasImage( userIDString, 5 ) )
{
return GetImage( userIDString, 5 );
}
if ( !HasImage( userIDString, 0 ) )
{
_plugin.GetPlayerAvatar( userIDString );
return GetImage( "naked_head_alive", 3 );
}
var imageBytes = GetImageBytes( userIDString, 0 );
var circleBytes = CropToCircle( imageBytes );
AddImage( circleBytes, userIDString, 5 );
return GetImage( "naked_head_alive", 3 );
}
public static byte[] CropToCircle( byte[] srcImage )
{
System.Drawing.Image sourceImage = System.Drawing.Bitmap.FromStream( new MemoryStream( srcImage ) );
System.Drawing.Image finalImage = new System.Drawing.Bitmap( sourceImage.Width, sourceImage.Height );
using ( System.Drawing.Graphics g = System.Drawing.Graphics.FromImage( finalImage ) )
{
System.Drawing.RectangleF r = new System.Drawing.RectangleF( 0, 0, sourceImage.Width, sourceImage.Height );
// enables smoothing of the edge of the circle (less pixelated)
g.SmoothingMode = SmoothingMode.AntiAlias;
// fills background color
using ( System.Drawing.Brush br = new System.Drawing.SolidBrush( System.Drawing.Color.Transparent ) )
{
g.FillRectangle( br, 0, 0, sourceImage.Width, sourceImage.Height );
}
// adds the new ellipse & draws the image again
GraphicsPath path = new GraphicsPath();
path.AddEllipse( r );
g.SetClip( path );
g.DrawImage( sourceImage, 0, 0 );
}
return ImageToByteArray( finalImage );
}
public static byte[] ImageToByteArray( System.Drawing.Image imageIn )
{
using ( var ms = new MemoryStream() )
{
imageIn.Save( ms, imageIn.RawFormat );
return ms.ToArray();
}
}
#endregion
#endregion
#endregion
#region Functions
public RelationshipManager.PlayerTeam GetTeam( BasePlayer player )
{
return GetTeam( player.userID );
}
public RelationshipManager.PlayerTeam GetTeam( ulong steamID )
{
return RelationshipManager.Instance.FindPlayersTeam( steamID );
}
public List<BasePlayer> GetOnlineMembersInTeam( List<ulong> members, ulong playerID )
{
var list = Pool.GetList<BasePlayer>();
foreach ( var memberID in members )
{
if ( !Settings.ShowOwnHealthBar && playerID == memberID )
{
continue;
}
var member = RelationshipManager.FindByID( memberID );
if ( member == null || !member.IsConnected )
{
continue;
}
list.Add( member );
}
return list;
}
public List<BasePlayer> GetOnlineMembersInTeam( List<ulong> members )
{
var list = Pool.GetList<BasePlayer>();
foreach ( var memberID in members )
{
var member = RelationshipManager.FindByID( memberID );
if ( member == null || !member.IsConnected )
{
continue;
}
list.Add( member );
}
return list;
}
#endregion
#region Commands
void ToggleHUDCommand( BasePlayer player, string command, string[] args )
{
var data = PlayerData.Get( player );
var team = GetTeam( player );
if ( data.ShowUI )
{
data.ShowUI = false;
}
else
{
data.ShowUI = true;
}
if ( team != null )
{
RefreshTeamGUIForTeam( team.members );
}
}
#endregion
#region Hooks
void OnServerInitialized()
{
if ( ImageLibrary == null )
{
PrintError( "Please install or update ImageLibrary by k1llyou before using TeamGUI, run the command o.reload TeamGUI once you install ImageLibrary." );
NextFrame( () =>
{
rust.RunServerCommand( "o.unload TeamGUI" );
} );
return;
}
_plugin = this;
try
{
_settingsFile = new JSONFile<ConfigData>( "TeamGUI", ConfigLocation.Config );
}
catch
{
PrintError( "Config file has errors within it, please verify you aren't missing commas or brackets." );
NextFrame( () =>
{
rust.RunServerCommand( "o.unload TeamGUI" );
} );
return;
}
permission.RegisterPermission( "teamgui.allow", this );
cmd.AddChatCommand( Settings.CommandName, this, ToggleHUDCommand );
PlayerData = new PlayerDataController<TeamGUIPlayerData>();
RegisterUICommands();
RegisterImages();
BuildUI();
foreach ( var player in BasePlayer.activePlayerList )
{
OnPlayerConnected( player );
}
HealthUpdateTimer = timer.Every( 1f, UpdateIcons );
}
void Unload()
{
DestroyUI();
_plugin = null;
HealthUpdateTimer?.Destroy();
}
void OnPlayerConnected( BasePlayer player )
{
GetPlayerAvatar( player.UserIDString );
var team = GetTeam( player );
timer.In( 1, () =>
{
if ( team != null )
{
RefreshTeamGUIForTeam( team.members );
}
} );
}
void OnPlayerDisconnected( BasePlayer player )
{
var team = GetTeam( player );
NextFrame( () =>
{
if ( team != null )
{
RefreshTeamGUIForTeam( team.members );
}
} );
}
void OnUserPermissionGranted( string id, string permName )
{
if ( permName != "teamgui.allow" )
{
return;
}
var team = RelationshipManager.Instance.FindPlayersTeam( Convert.ToUInt64( id ) );
if ( team != null )
{
RefreshTeamGUIForTeam( team.members );
}
}
void OnUserPermissionRevoked( string id, string permName )
{
if ( permName != "teamgui.allow" )
{
return;
}
var team = RelationshipManager.Instance.FindPlayersTeam( Convert.ToUInt64( id ) );
if ( team != null )
{
RefreshTeamGUIForTeam( team.members );
}
}
#region Team Hooks
object OnTeamDisband( RelationshipManager.PlayerTeam team )
{
var members = team.members.ToList();
NextFrame( () =>
{
RefreshTeamGUIForTeam( members );
} );
return null;
}
object OnTeamLeave( RelationshipManager.PlayerTeam team, BasePlayer player )
{
var members = team.members.ToList();
NextFrame( () =>
{
RefreshTeamGUIForTeam( members );
} );
return null;
}
object OnTeamKick( RelationshipManager.PlayerTeam team, BasePlayer player )
{
NextFrame( () =>
{
RefreshTeamGUIForTeam( team.members );
} );
return null;
}
object OnTeamCreated( BasePlayer player, RelationshipManager.PlayerTeam team )
{
RefreshTeamGUIForTeam( team.members );
return null;
}
object OnTeamAcceptInvite( RelationshipManager.PlayerTeam team, BasePlayer player )
{
NextFrame( () =>
{
RefreshTeamGUIForTeam( team.members );
} );
return null;
}
#endregion
#endregion
#region Player Data
public class TeamGUIPlayerData : BasePlayerData
{
public int HealthImageIndex;
public bool IsWounded;
public bool ShowUI = true;
public bool ImageSettingUp = false;
public void ReassignHealthImageIndex( BasePlayer player )
{
//Grab the correct health image (1 - 10 bars) based on current health floored
HealthImageIndex = Mathf.RoundToInt( player._health / player.MaxHealth() * 10 );
if ( HealthImageIndex == 0 && player.IsDead() == false )
{
//It would round down from <5 health to 0 health bars, so keep displaying 1 bar unless they are actually dead
HealthImageIndex = 1;
}
}
}
#endregion
#region Config
public class ConfigData
{
[JsonProperty("Icon Pixel Based Placement Per Team Member Index (0 is the first member)")]
public Dictionary<int, ConfigurableUIPlacement> PlacementToIndex = new Dictionary<int, ConfigurableUIPlacement>()
{
{ 0, new ConfigurableUIPlacement( 55, 55, 550, 500 )},
{ 1, new ConfigurableUIPlacement( 55, 55, 635, 500 )},
{ 2, new ConfigurableUIPlacement( 55, 55, 720, 500 )},
{ 3, new ConfigurableUIPlacement( 55, 55, 805, 500 )},
{ 4, new ConfigurableUIPlacement( 55, 55, 550, 420 )},
{ 5, new ConfigurableUIPlacement( 55, 55, 635, 420 )},
{ 6, new ConfigurableUIPlacement( 55, 55, 720, 420 )},
{ 7, new ConfigurableUIPlacement( 55, 55, 805, 420 )},
};
[JsonProperty( "Show Your Own Health Bar" )]
public bool ShowOwnHealthBar = true;
[JsonProperty( "Command Name for Player Hiding Team GUI" )]
public string CommandName = "teamhud";
}
public class ConfigurableUIPlacement
{
public ConfigurableUIPlacement( int xS, int yS, int xO, int yO )
{
xSize = xS;
ySize = yS;
xOffset = xO;
yOffset = yO;
}
public int xSize;
public int ySize;
public int xOffset;
public int yOffset;
}
#endregion
#region Framework
#region Player Data
public class BasePlayerData
{
[JsonIgnore]
public BasePlayer PlayerModel
{
get
{
if ( _player == null )
{
RelationshipManager.Instance.cachedPlayers.TryGetValue( userID, out _player );
}
else
{
if ( _player.IsDestroyed )
{
_player = null;
}
}
return _player;
}
}
private BasePlayer _player;
public ulong userID { get; set; }
public BasePlayerData()
{
}
public BasePlayerData( BasePlayer player ) : base()
{
userID = player.userID;
}
}
public class PlayerDataController<T> where T : BasePlayerData
{
[JsonPropertyAttribute( Required = Required.Always )]
private Dictionary<string, T> playerData { get; set; } = new Dictionary<string, T>();
[JsonIgnore]
private List<T> playerDataList = new List<T>();
private JSONFile<Dictionary<string, T>> _file;
private Timer _timer;
public IEnumerable<T> All { get { return playerDataList; } }
public PlayerDataController()
{
}
public PlayerDataController( string filename = null )
{
if ( filename == null )
{
return;
}
_file = new JSONFile<Dictionary<string, T>>( filename );
playerData = _file.Instance;
_timer = _plugin.timer.Every( 600f, () =>
{
_file.Save();
} );
}
[OnDeserialized]
internal void OnDeserializedMethod( StreamingContext context )
{
//Recreates the cached list after it is deserialized
//Someone smart would of saved it as a list instead of a dictionary and used the dictionary as the cache, OH WELL
playerDataList.AddRange( playerData.Values );
}
public void Unload()
{
if ( _file == null )
{
return;
}
_file.Save();
}
public T Get( string identifer )
{
T data;
if ( !playerData.TryGetValue( identifer, out data ) )
{
data = Activator.CreateInstance<T>();
data.userID = ulong.Parse( identifer );
playerData[ identifer ] = data;
playerDataList.Add( data );
}
return data;
}
public T Get( ulong userID )
{
return Get( userID.ToString() );
}
public T Get( BasePlayer player )
{
var data = Get( player.UserIDString );
return data;
}
public bool Has( ulong userID )
{
return playerData.ContainsKey( userID.ToString() );
}
public void Set( string userID, T data )
{
playerData[ userID ] = data;
}
}
#endregion
#region ImageLibrary
[PluginReference]
RustPlugin ImageLibrary;
public static bool ImageLibraryReady()
{
return _plugin.ImageLibrary != null;
}
public static string GetItemURL( string shortname, ulong skinID )
{
if ( _plugin.ImageLibrary == null )
{
_plugin.PrintError( "ImageLibrary not found!" );
return "";
}
string url = _plugin.ImageLibrary.Call( "GetImage", shortname, skinID, true ) as string;
return url;
}
public static string GetImage( string shortname, ulong skinID )
{
var str = _plugin.ImageLibrary.Call( "GetImage", shortname, skinID ) as string;
return str;
}
public static bool HasImage( string shortname, ulong skinID )
{
return ( _plugin.ImageLibrary.Call( "HasImage", shortname, skinID ) as bool? ) ?? false;
}
public static byte[] GetImageBytes( string shortname, ulong skinID = 0 )
{
var imageString = GetImage( shortname, skinID );
uint id;
if ( !uint.TryParse( imageString, out id ) )
{
return null;
}
return FileStorage.server.Get( id, FileStorage.Type.png, CommunityEntity.ServerInstance.net.ID );
}
public static void AddImage( string url, string shortname, ulong skinID )
{
_plugin.ImageLibrary.Call( "AddImage", url, shortname, skinID );
}
public static void AddImage( byte[] pngBytes, string shortname, ulong skinID )
{
_plugin.ImageLibrary.Call( "AddImageData", shortname, pngBytes, skinID );
}
#endregion
#region Configuration Files
public enum ConfigLocation
{
Data = 0,
Config = 1,
Logs = 2,
Plugins = 3,
Lang = 4,
Custom = 5,
}
public class JSONFile<Type> where Type : class
{
private DynamicConfigFile _file;
public string _name { get; set; }
public Type Instance { get; set; }
private ConfigLocation _location { get; set; }
private string _path { get; set; }
public JSONFile( string name, ConfigLocation location = ConfigLocation.Data, string path = null, string extension = ".json" )
{
_name = name.Replace( ".json", "" );
_location = location;
switch ( location )
{
case ConfigLocation.Data:
{
_path = $"{Oxide.Core.Interface.Oxide.DataDirectory}/{name}{extension}";
break;
}
case ConfigLocation.Config:
{
_path = $"{Oxide.Core.Interface.Oxide.ConfigDirectory}/{name}{extension}";
break;
}
case ConfigLocation.Logs:
{
_path = $"{Oxide.Core.Interface.Oxide.LogDirectory}/{name}{extension}";
break;
}
case ConfigLocation.Lang:
{
_path = $"{Oxide.Core.Interface.Oxide.LangDirectory}/{name}{extension}";
break;
}
case ConfigLocation.Custom:
{
_path = $"{path}/{name}{extension}";
break;
}
}
_file = new DynamicConfigFile( _path );
_file.Settings = new JsonSerializerSettings() { ReferenceLoopHandling = ReferenceLoopHandling.Ignore };
Init();
}
public virtual void Init()
{
Load();
Save();
Load();
}
public virtual void Load()
{
if ( !_file.Exists() )
{
Save();
}
Instance = _file.ReadObject<Type>();
if ( Instance == null )
{
Instance = Activator.CreateInstance<Type>();
Save();
}
return;
}
public virtual void Save()
{
_file.WriteObject( Instance );
return;
}
public virtual void Reload()
{
Load();
}
private void Unload( Plugin sender, PluginManager manager )
{
}
}
#endregion
#region UI
private void RegisterUICommands()
{
cmd.AddConsoleCommand( "ui.tuclose", this, AUCloseUICommand );
cmd.AddConsoleCommand( "ui.tuclicked", this, AUUIClickedCommands );
cmd.AddConsoleCommand( "ui.tuinput", this, AUUIInputCommand );
}
bool AUCloseUICommand( ConsoleSystem.Arg args )
{
UICallbackManager.OnUIClosedOnClient( args );
return true;
}
bool AUUIClickedCommands( ConsoleSystem.Arg args )
{
UICallbackManager.OnButtonClicked( args );
return true;
}
bool AUUIInputCommand( ConsoleSystem.Arg args )
{
UICallbackManager.OnInputFieldEntered( args );
return true;
}
#region Colors
public static class Colors
{
public static Color Transparent => new Color();
public static class Rust
{
public static readonly Color player = HexColor( 0x50, 0xa0, 0xf0 );
public static readonly Color admin = HexColor( 0xa0, 0xf0, 0x50 );
public static readonly Color dev = HexColor( 0xf0, 0xa0, 0x50 );
}
public static class Red
{
public static readonly Color lightsalmon = HexColor( 0xFF, 0xA0, 0x7A );
public static readonly Color salmon = HexColor( 0xFA, 0x80, 0x72 );
public static readonly Color darksalmon = HexColor( 0xE9, 0x96, 0x7A );
public static readonly Color lightcoral = HexColor( 0xF0, 0x80, 0x80 );
public static readonly Color indianred = HexColor( 0xCD, 0x5C, 0x5C );
public static readonly Color crimson = HexColor( 0xDC, 0x14, 0x3C );
public static readonly Color firebrick = HexColor( 0xB2, 0x22, 0x22 );
public static readonly Color red = HexColor( 0xFF, 0x00, 0x00 );
public static readonly Color darkred = HexColor( 0x8B, 0x00, 0x00 );
}
public static class Orange
{
public static readonly Color coral = HexColor( 0xFF, 0x7F, 0x50 );
public static readonly Color tomato = HexColor( 0xFF, 0x63, 0x47 );
public static readonly Color orangered = HexColor( 0xFF, 0x45, 0x00 );
public static readonly Color gold = HexColor( 0xFF, 0xD7, 0x00 );
public static readonly Color orange = HexColor( 0xFF, 0xA5, 0x00 );
public static readonly Color darkorange = HexColor( 0xFF, 0x8C, 0x00 );
}
public static class Yellow
{
public static readonly Color lightyellow = HexColor( 0xFF, 0xFF, 0xE0 );
public static readonly Color lemonchiffon = HexColor( 0xFF, 0xFA, 0xCD );
public static readonly Color lightgoldenrodyellow = HexColor( 0xFA, 0xFA, 0xD2 );
public static readonly Color papayawhip = HexColor( 0xFF, 0xEF, 0xD5 );
public static readonly Color moccasin = HexColor( 0xFF, 0xE4, 0xB5 );
public static readonly Color peachpuff = HexColor( 0xFF, 0xDA, 0xB9 );
public static readonly Color palegoldenrod = HexColor( 0xEE, 0xE8, 0xAA );
public static readonly Color khaki = HexColor( 0xF0, 0xE6, 0x8C );
public static readonly Color darkkhaki = HexColor( 0xBD, 0xB7, 0x6B );
public static readonly Color yellow = HexColor( 0xFF, 0xFF, 0x00 );
}
public static class Green
{
public static readonly Color lawngreen = HexColor( 0x7C, 0xFC, 0x00 );
public static readonly Color chartreuse = HexColor( 0x7F, 0xFF, 0x00 );
public static readonly Color limegreen = HexColor( 0x32, 0xCD, 0x32 );
public static readonly Color lime = HexColor( 0x00, 0xFF, 0x00 );
public static readonly Color forestgreen = HexColor( 0x22, 0x8B, 0x22 );
public static readonly Color green = HexColor( 0x00, 0x80, 0x00 );
public static readonly Color darkgreen = HexColor( 0x00, 0x64, 0x00 );
public static readonly Color greenyellow = HexColor( 0xAD, 0xFF, 0x2F );
public static readonly Color yellowgreen = HexColor( 0x9A, 0xCD, 0x32 );
public static readonly Color springgreen = HexColor( 0x00, 0xFF, 0x7F );
public static readonly Color mediumspringgreen = HexColor( 0x00, 0xFA, 0x9A );
public static readonly Color lightgreen = HexColor( 0x90, 0xEE, 0x90 );
public static readonly Color palegreen = HexColor( 0x98, 0xFB, 0x98 );
public static readonly Color darkseagreen = HexColor( 0x8F, 0xBC, 0x8F );
public static readonly Color mediumseagreen = HexColor( 0x3C, 0xB3, 0x71 );
public static readonly Color seagreen = HexColor( 0x2E, 0x8B, 0x57 );
public static readonly Color olive = HexColor( 0x80, 0x80, 0x00 );
public static readonly Color darkolivegreen = HexColor( 0x55, 0x6B, 0x2F );
public static readonly Color olivedrab = HexColor( 0x6B, 0x8E, 0x23 );
}
public static class Cyan
{
public static readonly Color lightcyan = HexColor( 0xE0, 0xFF, 0xFF );
public static readonly Color cyan = HexColor( 0x00, 0xFF, 0xFF );
public static readonly Color aqua = HexColor( 0x00, 0xFF, 0xFF );
public static readonly Color aquamarine = HexColor( 0x7F, 0xFF, 0xD4 );
public static readonly Color mediumaquamarine = HexColor( 0x66, 0xCD, 0xAA );
public static readonly Color paleturquoise = HexColor( 0xAF, 0xEE, 0xEE );
public static readonly Color turquoise = HexColor( 0x40, 0xE0, 0xD0 );
public static readonly Color mediumturquoise = HexColor( 0x48, 0xD1, 0xCC );
public static readonly Color darkturquoise = HexColor( 0x00, 0xCE, 0xD1 );
public static readonly Color lightseagreen = HexColor( 0x20, 0xB2, 0xAA );
public static readonly Color cadetblue = HexColor( 0x5F, 0x9E, 0xA0 );
public static readonly Color darkcyan = HexColor( 0x00, 0x8B, 0x8B );
public static readonly Color teal = HexColor( 0x00, 0x80, 0x80 );
}
public static class Blue
{
public static readonly Color powderblue = HexColor( 0xB0, 0xE0, 0xE6 );
public static readonly Color lightblue = HexColor( 0xAD, 0xD8, 0xE6 );
public static readonly Color lightskyblue = HexColor( 0x87, 0xCE, 0xFA );
public static readonly Color skyblue = HexColor( 0x87, 0xCE, 0xEB );
public static readonly Color deepskyblue = HexColor( 0x00, 0xBF, 0xFF );
public static readonly Color lightsteelblue = HexColor( 0xB0, 0xC4, 0xDE );
public static readonly Color dodgerblue = HexColor( 0x1E, 0x90, 0xFF );
public static readonly Color cornflowerblue = HexColor( 0x64, 0x95, 0xED );
public static readonly Color steelblue = HexColor( 0x46, 0x82, 0xB4 );
public static readonly Color royalblue = HexColor( 0x41, 0x69, 0xE1 );
public static readonly Color blue = HexColor( 0x00, 0x00, 0xFF );
public static readonly Color mediumblue = HexColor( 0x00, 0x00, 0xCD );
public static readonly Color darkblue = HexColor( 0x00, 0x00, 0x8B );
public static readonly Color navy = HexColor( 0x00, 0x00, 0x80 );
public static readonly Color midnightblue = HexColor( 0x19, 0x19, 0x70 );
public static readonly Color mediumslateblue = HexColor( 0x7B, 0x68, 0xEE );
public static readonly Color slateblue = HexColor( 0x6A, 0x5A, 0xCD );
public static readonly Color darkslateblue = HexColor( 0x48, 0x3D, 0x8B );
}
public static class Purple
{
public static readonly Color lavender = HexColor( 0xE6, 0xE6, 0xFA );
public static readonly Color thistle = HexColor( 0xD8, 0xBF, 0xD8 );
public static readonly Color plum = HexColor( 0xDD, 0xA0, 0xDD );
public static readonly Color violet = HexColor( 0xEE, 0x82, 0xEE );
public static readonly Color orchid = HexColor( 0xDA, 0x70, 0xD6 );
public static readonly Color fuchsia = HexColor( 0xFF, 0x00, 0xFF );
public static readonly Color magenta = HexColor( 0xFF, 0x00, 0xFF );
public static readonly Color mediumorchid = HexColor( 0xBA, 0x55, 0xD3 );
public static readonly Color mediumpurple = HexColor( 0x93, 0x70, 0xDB );
public static readonly Color blueviolet = HexColor( 0x8A, 0x2B, 0xE2 );
public static readonly Color darkviolet = HexColor( 0x94, 0x00, 0xD3 );
public static readonly Color darkorchid = HexColor( 0x99, 0x32, 0xCC );
public static readonly Color darkmagenta = HexColor( 0x8B, 0x00, 0x8B );
public static readonly Color purple = HexColor( 0x80, 0x00, 0x80 );
public static readonly Color indigo = HexColor( 0x4B, 0x00, 0x82 );
}
public static class Pink
{
public static readonly Color pink = HexColor( 0xFF, 0xC0, 0xCB );
public static readonly Color lightpink = HexColor( 0xFF, 0xB6, 0xC1 );
public static readonly Color hotpink = HexColor( 0xFF, 0x69, 0xB4 );
public static readonly Color deeppink = HexColor( 0xFF, 0x14, 0x93 );
public static readonly Color palevioletred = HexColor( 0xDB, 0x70, 0x93 );
public static readonly Color mediumvioletred = HexColor( 0xC7, 0x0, 0x85 );
}
public static class White
{
public static readonly Color white = HexColor( 0xFF, 0xFF, 0xFF );
public static readonly Color snow = HexColor( 0xFF, 0xFA, 0xFA );
public static readonly Color honeydew = HexColor( 0xF0, 0xFF, 0xF0 );
public static readonly Color mintcream = HexColor( 0xF5, 0xFF, 0xFA );
public static readonly Color azure = HexColor( 0xF0, 0xFF, 0xFF );
public static readonly Color aliceblue = HexColor( 0xF0, 0xF8, 0xFF );
public static readonly Color ghostwhite = HexColor( 0xF8, 0xF8, 0xFF );
public static readonly Color whitesmoke = HexColor( 0xF5, 0xF5, 0xF5 );
public static readonly Color seashell = HexColor( 0xFF, 0xF5, 0xEE );
public static readonly Color beige = HexColor( 0xF5, 0xF5, 0xDC );
public static readonly Color oldlace = HexColor( 0xFD, 0xF5, 0xE6 );
public static readonly Color floralwhite = HexColor( 0xFF, 0xFA, 0xF0 );
public static readonly Color ivory = HexColor( 0xFF, 0xFF, 0xF0 );
public static readonly Color antiquewhite = HexColor( 0xFA, 0xEB, 0xD7 );
public static readonly Color linen = HexColor( 0xFA, 0xF0, 0xE6 );
public static readonly Color lavenderblush = HexColor( 0xFF, 0xF0, 0xF5 );
}
public static class Grey
{
public static readonly Color gainsboro = HexColor( 0xDC, 0xDC, 0xDC );
public static readonly Color lightgray = HexColor( 0xD3, 0xD3, 0xD3 );
public static readonly Color silver = HexColor( 0xC0, 0xC0, 0xC0 );
public static readonly Color darkgray = HexColor( 0xA9, 0xA9, 0xA9 );
public static readonly Color gray = HexColor( 0x80, 0x80, 0x80 );
public static readonly Color dimgray = HexColor( 0x69, 0x69, 0x69 );
public static readonly Color lightslategray = HexColor( 0x77, 0x88, 0x99 );
public static readonly Color slategray = HexColor( 0x70, 0x80, 0x90 );
public static readonly Color darkslategray = HexColor( 0x2F, 0x4F, 0x4F );
public static readonly Color black = HexColor( 0x00, 0x00, 0x00 );
}
public static class Black
{
public static readonly Color gainsboro = HexColor( 0xDC, 0xDC, 0xDC );
public static readonly Color lightgray = HexColor( 0xD3, 0xD3, 0xD3 );
public static readonly Color silver = HexColor( 0xC0, 0xC0, 0xC0 );
public static readonly Color darkgray = HexColor( 0xA9, 0xA9, 0xA9 );
public static readonly Color gray = HexColor( 0x80, 0x80, 0x80 );
public static readonly Color dimgray = HexColor( 0x69, 0x69, 0x69 );
public static readonly Color lightslategray = HexColor( 0x77, 0x88, 0x99 );
public static readonly Color slategray = HexColor( 0x70, 0x80, 0x90 );
public static readonly Color darkslategray = HexColor( 0x2F, 0x4F, 0x4F );
public static readonly Color black = HexColor( 0x00, 0x00, 0x00 );
}
public static class Brown
{
public static readonly Color cornsilk = HexColor( 0xFF, 0xF8, 0xDC );
public static readonly Color blanchedalmond = HexColor( 0xFF, 0xEB, 0xCD );
public static readonly Color bisque = HexColor( 0xFF, 0xE4, 0xC4 );
public static readonly Color navajowhite = HexColor( 0xFF, 0xDE, 0xAD );
public stat
// ... [Code preview truncated due to length. Full source in attached file] ...