Difference between revisions of "PrintMiniFix"

From WikiPrizm
Jump to navigationJump to search
(Created page with '== Synopsis == This is a routine that displays a text in small (glyph) font on the screen. === Definition === <nowiki>int PrintMiniFix( int x, int y, const char*Msg, const int …')
 
(→‎Comments: I didn't write this :))
Line 35: Line 35:
 
=== Outputs ===
 
=== Outputs ===
 
Small font string on-screen.
 
Small font string on-screen.
 
== Comments ==
 
Cheers to Shaun "Merthsoft" Mcfall for this routine.
 
  
 
=== Usage Example ===
 
=== Usage Example ===

Revision as of 00:01, 17 May 2012

Synopsis

This is a routine that displays a text in small (glyph) font on the screen.

Definition

int PrintMiniFix( int x, int y, const char*Msg, const int flags, const short color, const short bcolor ){
int i = 0, dx;
unsigned short width;
void*p;

   while ( Msg[ i ] ){
      p = GetMiniGlyphPtr( Msg[ i ], &width );
      dx = ( 12 - width ) / 2;
      if ( dx > 0 ) {
         PrintMiniGlyph( x, y, (void*)empty, flags, dx, 0, 0, 0, 0, color, bcolor, 0 );
      }else dx = 0;
      PrintMiniGlyph( x+dx, y, p, flags, width, 0, 0, 0, 0, color, bcolor, 0 );
      if ( width+dx < 12 ){
         PrintMiniGlyph( x+width+dx, y, (void*)empty, flags, 12-width-dx, 0, 0, 0, 0, color, bcolor, 0 );
      }
      x += 12;
      i++;
   }
   return x;
}
const short empty[18] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };

Inputs

  • int x: X-coordinate of top-left of text
  • int y: Y-coordinate of top-left of text
  • const char* Msg: string to display
  • const int flags: (unknown)
  • const short color: Text foreground color
  • const short bcolor: Text background color

Outputs

Small font string on-screen.

Usage Example

PrintMiniFix(0, 175,
         "Oh look a string at the bottom of the screen.",
         0, COLOR_WHITE, COLOR_BLACK);