SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Plugin Development

Reply
 
Thread Tools Display Modes
Old 17/01/2009, 03:15 PM   #21
yom
High-roller
 
Join Date: Jul 2006
Posts: 2,005
Reputation: 5
Default Re: [REL] Console Colored Text 0.2 (New version)

Thanks, that fixed it

I suggest you change functions names
Code:
SetConsoleColors(colors);
GetConsoleColors();
yom is offline   Reply With Quote
Old 17/01/2009, 03:21 PM   #22
cosmy
Big Clucker
 
Join Date: Nov 2007
Posts: 160
Reputation: 21
Default Re: [REL] Console Colored Text 0.2 (New version)

Quote:
Originally Posted by 0rb
Thanks, that fixed it
Code:
new default_colors = GetConsoleTextColor();

SetConsoleTextColor(0x04);
printf("test");

SetConsoleTextColor(default_colors);

I suggest you change functions names
Code:
SetConsoleColors(colors);
GetConsoleColors();
you can do this with pawn :P

Code:
#define SetConsoleTextColors(%1) SetConsoleTextColor(%1)
#define GetConsoleTextColors(%1) GetConsoleTextColor(%1)

but thank's i will fix in the next version :P
cosmy is offline   Reply With Quote
Old 17/01/2009, 03:32 PM   #23
yom
High-roller
 
Join Date: Jul 2006
Posts: 2,005
Reputation: 5
Default Re: [REL] Console Colored Text 0.2 (New version)

Just made correct printc and printfc:
Code:
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);\
}
yom is offline   Reply With Quote
Old 17/01/2009, 04:06 PM   #24
cosmy
Big Clucker
 
Join Date: Nov 2007
Posts: 160
Reputation: 21
Default Re: [REL] Console Colored Text 0.2 (New version)

Quote:
Originally Posted by 0rb
Just made correct printc and printfc:
Code:
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 ^^
cosmy is offline   Reply With Quote
Old 17/01/2009, 06:47 PM   #25
yom
High-roller
 
Join Date: Jul 2006
Posts: 2,005
Reputation: 5
Default Re: [REL] Console Colored Text 0.2 (New version)

Bah, you quoted old versions.

Also, colors(background, text); :

edited:
Code:
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!
yom is offline   Reply With Quote
Old 17/01/2009, 06:51 PM   #26
cosmy
Big Clucker
 
Join Date: Nov 2007
Posts: 160
Reputation: 21
Default Re: [REL] Console Colored Text 0.2 (New version)

Quote:
Originally Posted by 0rb
Bah, you quoted old versions.

Also, colors(background, text); :

Code:
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 )
cosmy is offline   Reply With Quote
Old 17/01/2009, 07:09 PM   #27
yom
High-roller
 
Join Date: Jul 2006
Posts: 2,005
Reputation: 5
Default Re: [REL] Console Colored Text 0.2 (New version)

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:
Code:
//until you change functions names :)

native GetConsoleColors();
native SetConsoleColors(colors);

#define GetConsoleColors() \
  GetConsoleTextColor()

#define SetConsoleColors(%1) \
  SetConsoleTextColor(%1)
Code:
//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)
Code:
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')
yom is offline   Reply With Quote
Old 18/01/2009, 09:31 AM   #28
ғαιιοцт
High-roller
 
ғαιιοцт's Avatar
 
Join Date: Feb 2008
Posts: 1,706
Reputation: 188
Default Re: [REL] Console Colored Text 0.2 (New version)

this plugin is cool nice dude!
ғαιιοцт is offline   Reply With Quote
Old 18/01/2009, 04:33 PM   #29
cosmy
Big Clucker
 
Join Date: Nov 2007
Posts: 160
Reputation: 21
Default Re: [REL] Console Colored Text 0.2 (New version)

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?

cosmy is offline   Reply With Quote
Old 18/01/2009, 05:02 PM   #30
yom
High-roller
 
Join Date: Jul 2006
Posts: 2,005
Reputation: 5
Default Re: [REL] Console Colored Text 0.2 (New version)

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.
Code:
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
yom is offline   Reply With Quote
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


Similar Threads
Thread Thread Starter Forum Replies Last Post
[FilterScript] [FS] Text -> Haystacks! [Version 1.2 Released! Now Saving!] Pghpunkid Filterscripts 52 19/05/2016 09:54 PM
[FilterScript] [FS] Colored Money [0.2X] lavamike Filterscripts 38 22/07/2013 03:59 PM
[FilterScript] [FS] Colored Health Bar (v 4.0) OKStyle Релизы/Releases 9 21/09/2010 01:58 PM
How to input text into player console? Haron Help Archive 2 24/02/2010 07:29 PM
Colored Text FlatMaN Help Archive 6 15/01/2010 03:01 PM


All times are GMT. The time now is 06:25 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.