Re: [REL] Console Colored Text 0.2 (New version) -
yom - 17.01.2009
Just made correct printc and printfc:
pawn Код:
native printc(colors, const string[]);
native printfc(colors, const format[], {Float,_}:...);
new g_console_colors;
#define printfc(%1,%2); \
{\
g_console_colors = GetConsoleTextColor();\
SetConsoleTextColor(%1);\
printf(%2);\
SetConsoleTextColor(g_console_colors);\
}
#define printc(%1,%2); \
{\
g_console_colors = GetConsoleTextColor();\
SetConsoleTextColor(%1);\
print(%2);\
SetConsoleTextColor(g_console_colors);\
}
Re: [REL] Console Colored Text 0.2 (New version) -
cosmy - 17.01.2009
Quote:
Originally Posted by 0rb
Just made correct printc and printfc:
pawn Код:
new g_console_colors;
#define printfc(%1,%2) \ g_console_colors = GetConsoleTextColor();\ SetConsoleTextColor(%1);\ printf(%2);\ SetConsoleTextColor(g_console_colors)
#define printc(%1,%2) \ g_console_colors = GetConsoleTextColor();\ SetConsoleTextColor(%1);\ print(%2);\ SetConsoleTextColor(g_console_colors)
//or.. stock printc(colors, string[]) { new old_colors = GetConsoleTextColor(); SetConsoleTextColor(colors); print(string); SetConsoleTextColor(old_colors); }
|
nice ^^
Re: [REL] Console Colored Text 0.2 (New version) -
yom - 17.01.2009
Bah, you quoted old versions.
Also, colors(background, text); :
edited:
pawn Код:
enum e_console_color
{
BLACK,
BLUE,
GREEN,
AQUA,
RED,
PURPLE,
YELLOW,
WHITE,
GRAY,
LIGHTBLUE,
LIGHTGREEN,
LIGHTAQUA,
LIGHTRED,
LIGHTPURLE,
LIGHTYELLOW,
BRIGHTWHITE
}
native colors(e_console_color:text, e_console_color:background);
#define colors(%1,%2) \
(_:%1 + (16 * _:%2))
Sorry for partially hijacking this topic

but i think it's useful to post this. Maybe modify your .inc with all those things!
Re: [REL] Console Colored Text 0.2 (New version) -
cosmy - 17.01.2009
Quote:
Originally Posted by 0rb
Bah, you quoted old versions.
Also, colors(background, text); :
pawn Код:
enum e_console_color { BLACK, BLUE, GREEN, AQUA, RED, PURPLE, YELLOW, WHITE, GRAY, LIGHTBLUE, LIGHTGREEN, LIGHTAQUA, LIGHTRED, LIGHTPURLE, LIGHTYELLOW, BRIGHTWHITE }
//native colors(e_console_color:background = BLACK, e_console_color:text = WHITE);
colors(e_console_color:background = BLACK, e_console_color:text = WHITE) return _:text + (16 * _:background);
Sorry for partially hijacking this topic  but i think it's useful to post this. Maybe modify your .inc with all those things!
|
np. i add all this in the next version and i give credits(of corse

)
Re: [REL] Console Colored Text 0.2 (New version) -
yom - 17.01.2009
Edited my last post: arguments was mixed, and converted as a macro
Edit: some other things, but now i can't think of something else to do with it :P:
pawn Код:
//until you change functions names :)
native GetConsoleColors();
native SetConsoleColors(colors);
#define GetConsoleColors() \
GetConsoleTextColor()
#define SetConsoleColors(%1) \
SetConsoleTextColor(%1)
pawn Код:
//and then, MAYBE also replace all *Foreground* by *Text*
native GetConsoleForegroundColor();
native GetConsoleBackgroundColor();
native SetConsoleForegroundColor(e_console_color:color);
native SetConsoleBackgroundColor(e_console_color:color);
native SetConsoleColorsEx(e_console_color:foreground, e_console_color:background);
#define GetConsoleForegroundColor() \
(GetConsoleColors() & 0xF)
#define GetConsoleBackgroundColor() \
(GetConsoleColors() >> 4 & 0xF)
#define SetConsoleForegroundColor(%1) \
SetConsoleColors(GetConsoleBackgroundColor() << 4 | _:%1)
#define SetConsoleBackgroundColor(%1) \
SetConsoleColors(_:%1 << 4 | GetConsoleForegroundColor())
#define SetConsoleColorsEx(%1,%2) \
SetConsoleColors(_:%2 << 4 | _:%1)
Also renamed colors function because that name can be already used for a variable or whatever..and made it using bit operation (more efficient, i think)
pawn Код:
native ConsoleColors(e_console_color:foreground, e_console_color:background);
#define ConsoleColors(%1,%2) \
(_:%2 << 4 | _:%1)
that's all, i think.
SUGGESTIONS if possible:
GetConsoleBufferWidth : returns the max characters of a line
GetConsoleBufferHeight : returns max lines that can be displayed (without 'overwriting')
Re: [REL] Console Colored Text 0.2 (New version) -
ғαιιοцт - 18.01.2009
this plugin is cool

nice dude!
Re: [REL] Console Colored Text 0.2 (New version) -
cosmy - 18.01.2009
Quote:
Originally Posted by 0rb
SUGGESTIONS if possible:
GetConsoleBufferWidth : returns the max characters of a line
GetConsoleBufferHeight : returns max lines that can be displayed (without 'overwriting')
|
can you specify the params of these functions?
Re: [REL] Console Colored Text 0.2 (New version) -
yom - 18.01.2009
Well, no params, only return value, or maybe
GetConsoleBufferSize(&width, &height) //width in 'characters', height in 'lines'
So if you know the width buffer, you can print string of the same length, for making nice tables for example

. And height buffer can be useful for clearing the console for example
But that's no more related to console colors. I also wonder if it's possible to move cursor, as originally possible in Pawn, ad get/set the color of only where the cursor is (this join my other suggestion of start/end, which you said is impossible because of logprintf, but i really think it's possible to get and set the color of only 1 'cell' of the console buffer). So we can make colored games like tetris or whatever.
pawn Код:
GetConsoleCursorPos(&x, &y);
SetConsoleCursorPos(x, y);
GetConsoleCell(x, y, &character, &foreground, &background);
SetConsoleCell(x, y, character, e_console_color:foreground, e_console_color:background);
GetConsoleBuffer(startx, starty, endx, endy, bufferdata[], size = sizeof bufferdata); //not sure for those..
SetConsoleBuffer(startx, starty, endx, endy, bufferdata[], size = sizeof bufferdata); //but can be scripted in Pawn
Re: [REL] Console Colored Text 0.2 (New version) -
cosmy - 18.01.2009
this is a preview of the next version :P
Код:
/*
Console Colored Text 0.3
Author(s):
- Cosmy
- 0rb
Version log:
0.3
- Now SetConsoleTextColor() and GetConsoleTextColor() are called SetConsoleTextColors() and GetConsoleTextColors().
- Added an enum with all possible colors (i think).
- Added printc() and printfc() functions.
- Added GetConsoleForegroundColor(), GetConsoleBackgroundColor(), SetConsoleForegroundColor(), SetConsoleBackgroundColor() and SetConsoleColors().
- Deleted all old defines.
0.2
- Added GetConsoleTextColor() function.
0.1
- First release.
*/
#pragma unused g_console_colors
native SetConsoleTextColors(Attributes);
native GetConsoleTextColors();
new g_console_colors;
enum e_console_color
{
BLACK,
BLUE,
GREEN,
AQUA,
RED,
PURPLE,
YELLOW,
WHITE,
GRAY,
LIGHTBLUE,
LIGHTGREEN,
LIGHTAQUA,
LIGHTRED,
LIGHTPURLE,
LIGHTYELLOW,
BRIGHTWHITE
}
/* printc(colors, const string[]) */
#define printc(%1,%2); \
{\
g_console_colors = GetConsoleTextColors();\
SetConsoleTextColors(%1);\
print(%2);\
SetConsoleTextColors(g_console_colors);\
}
/* printfc(colors, const format[], {Float,_}:...) */
#define printfc(%1,%2); \
{\
g_console_colors = GetConsoleTextColors();\
SetConsoleTextColors(%1);\
printf(%2);\
SetConsoleTextColors(g_console_colors);\
}
/* GetConsoleForegroundColor() */
#define GetConsoleForegroundColor() \
(GetConsoleTextColors() & 0xF)
/* GetConsoleBackgroundColor() */
#define GetConsoleBackgroundColor() \
(GetConsoleTextColors() >> 4 & 0xF)
/* SetConsoleForegroundColor(e_console_color:color) */
#define SetConsoleForegroundColor(%1) \
SetConsoleTextColors(GetConsoleBackgroundColor() << 4 | _:%1)
/* SetConsoleBackgroundColor(e_console_color:color) */
#define SetConsoleBackgroundColor(%1) \
SetConsoleTextColors(_:%1 << 4 | GetConsoleForegroundColor())
/* SetConsoleColors(e_console_color:foreground, e_console_color:background) */
#define SetConsoleColors(%1,%2) \
SetConsoleTextColors(_:%2 << 4 | _:%1)
Re: [REL] Console Colored Text 0.2 (New version) -
yom - 19.01.2009
I made
pawn Код:
SetConsoleCellData(x, y, character, e_console_color:foreground, e_console_color:background);
pawn Код:
new str[] = "Random colored string out of nowhere :)";
for (new i; i < sizeof str - 1; i++)
SetConsoleCellData(10 + i, 20, str[i], e_console_color:(random(15)+1), e_console_color:BLACK);
Interested?
Re: [REL] Console Colored Text 0.2 (New version) -
ғαιιοцт - 20.01.2009
it looks funny but i don't think many people will use so many colors in one line ><
Re: [REL] Console Colored Text 0.2 (New version) -
cosmy - 20.01.2009
Quote:
Originally Posted by 0rb
I made
pawn Код:
SetConsoleCellData(x, y, character, e_console_color:foreground, e_console_color:background);
pawn Код:
new str[] = "Random colored string out of nowhere :)"; for (new i; i < sizeof str - 1; i++) SetConsoleCellData(10 + i, 20, str[i], e_console_color:(random(15)+1), e_console_color:BLACK);
Interested? 
|
nice !!! if you wanna give me the source of the function i can add in the next version
Re: [REL] Console Colored Text 0.2 (New version) -
yom - 22.01.2009
Well it's basically something like this:
pawn Код:
//SetConsoleCellsData(x, y, length, character, foreground_color, background_color);
//#define SetConsoleCellData(%1,%2,%3,%4,%5) SetConsoleCellsData(%1,%2,1,%3,%4,%5)
static cell AMX_NATIVE_CALL n_SetConsoleCellsData(AMX *amx, cell *params)
{
HANDLE Console = GetStdHandle(STD_OUTPUT_HANDLE);
COORD Coords = {(SHORT)params[1], (SHORT)params[2]};
DWORD Length = (DWORD)params[3];
WCHAR Character = (WCHAR)params[4];
WORD Colors = ((WORD)params[6] << 4 | (WORD)params[5]);
FillConsoleOutputCharacter(Console, Character, Length, Coords, NULL);
FillConsoleOutputAttribute(Console, Colors, Length, Coords, NULL);
return 1;
}
I make a plugin with <almost> all possible console functions

i'll maybe release it once i got buffers system working fine.
Re: [REL] Console Colored Text 0.2 (New version) -
cosmy - 26.01.2009
Quote:
Originally Posted by 0rb
Well it's basically something like this:
pawn Код:
//SetConsoleCellsData(x, y, length, character, foreground_color, background_color); //#define SetConsoleCellData(%1,%2,%3,%4,%5) SetConsoleCellsData(%1,%2,1,%3,%4,%5) static cell AMX_NATIVE_CALL n_SetConsoleCellsData(AMX *amx, cell *params) { HANDLE Console = GetStdHandle(STD_OUTPUT_HANDLE);
COORD Coords = {(SHORT)params[1], (SHORT)params[2]}; DWORD Length = (DWORD)params[3]; WCHAR Character = (WCHAR)params[4]; WORD Colors = ((WORD)params[6] << 4 | (WORD)params[5]);
FillConsoleOutputCharacter(Console, Character, Length, Coords, NULL); FillConsoleOutputAttribute(Console, Colors, Length, Coords, NULL);
return 1; }
I make a plugin with <almost> all possible console functions  i'll maybe release it once i got buffers system working fine.
|
i can help you, if you want...
Re: [REL] Console Colored Text 0.2 (New version) -
UsaBoy91 - 12.07.2009
lol cosmy, this isn't the WHOLE surse , this is a bollshit... post it or you'll be reported
Re: [REL] Console Colored Text 0.2 (New version) -
MJ! - 11.12.2009
New download link ?
REL Console Colored Text 0 2 New version -
Unpally09 - 13.12.2009
Has the new version of PlayOn messed up anyones else's plugins? My old plugins work but when I try to install a new one, I get "You plugin is not compatible with the new version of PlayOn." The weird thing is I am using the same API as all my older plugins that work. Any ideas?
Re: [REL] Console Colored Text 0.2 (New version) -
cosmy - 14.12.2009
I remake it because i don't have it anymore. Now just wait a moment...
EDIT:
bin + src:
http://www27.zippyshare.com/v/74631330/file.html
REL Console Colored Text 0 2 New version -
onenife09 - 14.12.2009
Has the new version of PlayOn messed up anyones else's plugins? My old plugins work but when I try to install a new one, I get "You plugin is not compatible with the new version of PlayOn." The weird thing is I am using the same API as all my older plugins that work. Any ideas?
Re: [REL] Console Colored Text 0.2 (New version) -
armyoftwo - 25.09.2010
really nice plugin,
Код:
stock SendConsoleText(text[], color)
{
SetConsoleTextColors(color);
printf("%s", text);
SetConsoleTextColors(CONSOLE_DEFAULT);
}
Use this if you want