Welcome
Welcome to a320

You are currently viewing our boards as a guest, which gives you limited access to view most discussions and access our other features. By joining our free community, you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content, and access many other special features. Registration is fast, simple, and absolutely free, so please, join our community today!

[Programming-Howto] Usuage of stringCompiler.exe & Text

Any and all A320 homebrew topics

Moderator: Moderators

[Programming-Howto] Usuage of stringCompiler.exe & Text

Postby joyrider on Sun May 03, 2009 10:41 pm

Ok guys after a bit of fidling around i managed to find a way on how to write text to the screen and how to create a new default font to use for your program !
I thought i might explain it here since it wasn't really obvious to me and took me a while to figure out. Do note i only have tested the result using the sdk in windows since i don't have my dingoo yet. Here i go :

1) Writing text to the screen :
------------------------------------
It seems the font is defined in the basefont.sbn file, this file should be included in your directory where your game / app resides. So copy it over to the folder !

to actually write text to the screen do the following :
- init the S2D engine as usual and then use the following :
Code: Select all
StringManager *Sm = new StringManager(); //create a string manager instance
Pixel *Color = new Pixel(255,255,255); // create a color for the text
VisString *String = new VisString("Some Text"); // create a visstring instance with some default text
Rect DrawRect; //coordinates where we will draw (the left & Top)
DrawRect.bottom = 240;
DrawRect.left = 50;
DrawRect.right = 320;
DrawRect.top = 50;
Sm->Init(English,""); // i'm not too sure what the 2nd parameter should hold but it could be the path where the basefont.sbn file is
Sm->SetVRAMPtr(g_pEng->m_pDraw2D->GetVRAMPtr(),320,240); //g_pEng is your Engine instance
Sm->DrawString(String,*Color,DrawRect); //Draw the string


2) Change The default font (/ generated new basefont.sbn file)
---------------------------------------------------------------------------
- goto the tools folder of the SDK you'll see a font.xml and a stringcompiler.exe file
- Right Click and drag the font.xml file onto the stringcompiler.exe file and choose "open with" if a context menu pops up.
- Next select your font settings and press ok.
- a new basefont.sbn will be generated
- copy the basefont.sbn file to your projects directory replacing the old one if you had already copied one over.

and you have your new font !!!
Pretty easy once you know how to use it !

cheers
willems davy
aka joyrider
joyrider
 
Posts: 77
Joined: Sun May 03, 2009 4:27 pm

Re: [Programming-Howto] Usuage of stringCompiler.exe & Text

Postby Wiredbomb0 on Sun May 10, 2009 10:23 pm

OMG! Thank! This is so much easier then what I planned to do. I planned to use the PutPixel to draw each pixel of each character, so now I don't have to waste time with that.
Wiredbomb0
 
Posts: 166
Joined: Thu Apr 23, 2009 10:08 am
Location: Victoria, Australia

Re: [Programming-Howto] Usuage of stringCompiler.exe & Text

Postby SiENcE on Mon May 11, 2009 12:58 am

You should really read the doxygen docu of the sdk :-).

But the docu is a little bit outdated :-(.
"InitBaseFont" don't exist...the basefont.sbn is loaded automatically.

I think it's done in:
Code: Select all
m_StrMgr.Init( GetCurLanguage(), _LS("") );


Here is an example, how to convert an int into a string (char*) and display it at a specific position on the screen.
Code: Select all
char string[50];

Point p(m_iScreenWidth>>1,0);
p.x = 100;
p.y = 100;

Pixel color;
color.rgb(0xff,0xff,0xff);

int x = 1;
sprintf( string, "%d", x );
VisString vistr( _LS(string) );
Sm.DrawString( &vistr, color, ANCHOR_RIGHT|ANCHOR_TOP, p);


The DrawString function I used in the upper example is also not fully documented. The one i used is also not in the Documentation. You can only find the definition in the header file (s2dengine_stringres.h).

Code: Select all
        /// draw string
   void         DrawString(
                  VisString* str,         //[in] string
                  Pixel aColor,         //[in] string color
                  u32 anchor,            //[in] anchor type
                   Point& aPoint         //[in] point
               );
SiENcE
 
Posts: 67
Joined: Wed Apr 29, 2009 9:19 am
Location: Berlin/Germany

Re: [Programming-Howto] Usuage of stringCompiler.exe & Text

Postby Wiredbomb0 on Mon May 11, 2009 7:37 am

Wow, that was easier then I thought LOL!

Once I had copied the basefont, everything worked like it was supposed to.

Do you guys know why:

A320_SCREEN_WIDTH/2
A320_SCREEN_HEIGHT/2

Isn't the center of the screen?
Wiredbomb0
 
Posts: 166
Joined: Thu Apr 23, 2009 10:08 am
Location: Victoria, Australia


Return to Homebrew

Who is online

Users browsing this forum: No registered users and 0 guests