Raised This Month: $7 Target: $400
 1% 

[INC] ColorLib


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
c0rp3n
Junior Member
Join Date: Jan 2019
Location: Derbyshire, UK
Old 01-12-2020 , 04:12   [INC] ColorLib
Reply With Quote #1

ColorLib is built as a replacement for Colors, it uses a a less naive approach to formatting messages to improve the performance of C* functions.

Why?
The reason for this is that Colors and More Colors both make heavy use of many ReplaceString operations each one looping through the buffer being formatted, whereas this could be avoided by writing a single pass formatter as used here and was done for ColorVariables.
And to why replace ColorVariables? it also adds extra overhead with forwards and allowing for more "dynamic" colors, which isnt always needed.

So ColorLib was created.

Performance:
ColorLib is currently twice over twice as fast as MultiColors when using CPrintToChat, further and improved benchmarks will be availible at the GitHub Repository

Example:
Code:
#pragma semicolon 1
#pragma newdecls required

#include <sourcemod>
#include <colorlib>

public void OnPluginStart()
{
    RegConsoleCmd("sm_colorlib", Command_ColorLib);
}

public Action Command_ColorLib(int client, int args)
{
    CPrintToChat(client, "CPrintToChat - {darkblue}%s - {darkred}%s", "Test", "Test");
    CPrintToChatAll("CPrintToChatAll - {darkblue}%s - {darkred}%s", "Test", "Test");
    CPrintToChatEx(client, client, "CPrintToChatEx - {darkblue}%s - {darkred}%s", "Test", "Test");
    CPrintToChatAllEx(client, "CPrintToChatAllEx - {darkblue}%s - {darkred}%s", "Test", "Test");

    CReplyToCommand(client, "CReplyToCommand - {darkblue}%s - {darkred}%s", "Test", "Test");
    CReplyToCommandEx(client, client, "CReplyToCommandEx - {darkblue}%s - {darkred}%s", "Test", "Test");

    CPrintToServer("CPrintToServer - {darkblue}%s - {darkred}%s", "Test", "Test");
}
More info and download at the GitHub Repository
c0rp3n is offline
404UNF
( ͡ ͜ʖ ͡)
Join Date: Dec 2011
Location: 🍁
Old 01-13-2020 , 13:03   Re: [INC] ColorLib
Reply With Quote #2

Think I'll add support for this to my ST3 syntax highlighting. Very nice stuff.
__________________
Plugin Developer for Creators.TF

404UNF is offline
Ragenewb
AlliedModders Donor
Join Date: May 2017
Location: Crashing Hale
Old 01-13-2020 , 23:30   Re: [INC] ColorLib
Reply With Quote #3

This is awesome, thanks for this.
__________________
Over-engineering is underrated.

GitHub
Ragenewb is offline
c0rp3n
Junior Member
Join Date: Jan 2019
Location: Derbyshire, UK
Old 01-15-2020 , 12:57   Re: [INC] ColorLib
Reply With Quote #4

Thanks, I'd originally planned this as an extension, but spent too much time fighting with AMBuild, so that has been delayed till I either stop hating it or I wait uppon the Rust bindings.


I shall be improving color customisation by making the color generator configurable without touching code with a config file.
__________________
Plugin Developer for CLWO.eu, ex Mythical Gaming and Traitors Cave.
c0rp3n is offline
Maxximou5
AlliedModders Donor
Join Date: Feb 2013
Old 01-15-2020 , 13:42   Re: [INC] ColorLib
Reply With Quote #5

Thanks for this! I'm going to be using this in the next version of my Deathmatch plugin.
__________________
Maxximou5 is offline
Bara
AlliedModders Donor
Join Date: Apr 2012
Location: Germany
Old 01-17-2020 , 20:11   Re: [INC] ColorLib
Reply With Quote #6



Will already used in TTT (release soon).
__________________
Bara is offline
Ilusion9
Veteran Member
Join Date: Jun 2018
Location: Romania
Old 01-23-2020 , 10:26   Re: [INC] ColorLib
Reply With Quote #7

Already using in my plugins.
Clean code, good job.
__________________
Ilusion9 is offline
Ragenewb
AlliedModders Donor
Join Date: May 2017
Location: Crashing Hale
Old 01-23-2020 , 21:47   Re: [INC] ColorLib
Reply With Quote #8

Hey I'm running into some chaos when using the inc.



The stuff ->
PHP Code:
#include <colorlib>

public void OnPluginStart()
{
    
char strAnnounce[256];
    
strcopy(strAnnouncesizeof(strAnnounce), "You can set your {red}Boss Difficulty{default} by typing {red}/difficulty{default}.");
    
CPrintToChatAll("{olive][VSH 2]{default} %s"strAnnounce);

Using latest download from the GitHub, SM1.10 compiler if that matters at all.
__________________
Over-engineering is underrated.

GitHub
Ragenewb is offline
hmmmmm
Great Tester of Whatever
Join Date: Mar 2017
Location: ...
Old 01-23-2020 , 22:53   Re: [INC] ColorLib
Reply With Quote #9

"{olive][VSH 2]{default} %s"

You're missing a closing brace for olive. Should be:
"{olive}[VSH 2]{default} %s"
hmmmmm is offline
Ragenewb
AlliedModders Donor
Join Date: May 2017
Location: Crashing Hale
Old 01-25-2020 , 16:37   Re: [INC] ColorLib
Reply With Quote #10

Quote:
Originally Posted by hmmmmm View Post
"{olive][VSH 2]{default} %s"

You're missing a closing brace for olive. Should be:
"{olive}[VSH 2]{default} %s"
(╯ ͡ ͜ʖ ͡)╯︵ /(.□ . \)

I made a small reproduction plugin and fat-fingered that.

With fixed code:
Spoiler


Provides this output:
Spoiler
__________________
Over-engineering is underrated.

GitHub
Ragenewb is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 12:34.


Powered by vBulletin®
Copyright ©2000 - 2020, vBulletin Solutions, Inc.
Theme made by Freecode