Wednesday, 2 December 2009

Nexlib CTextManager



Texts can now have 2 colours to the background (up from 1) with allows for more pleasing backgrounds. This puts the total colours allowed for a text being created 14.

8: text
4: frame border
2: frame background

The example screen was created with the code:

/* TEXT TEST */

CTextManager *pTxt = new CTextManager;

int bg = 0;
int frm[4];

pTxt->Init_RegTileMap256(0, BG_TILE_MEM_SUB(bg), BG_MAP_MEM_SUB(bg), BG_PALETTE_SUB, NULL);  

// create the frames
frm[0] = pTxt->MakeFrame(0, 160, SCREEN_WIDTH, SCREEN_HEIGHT, true);

frm[1] = pTxt->MakeFrame(0, 0, SCREEN_WIDTH / 2, 72, true);

frm[2] = pTxt->MakeFrame(SCREEN_WIDTH / 2, 0, SCREEN_WIDTH, 160, true);

frm[3] = pTxt->MakeFrame(0, 75, SCREEN_WIDTH / 2, 160, true);

// print the text using the frames
pTxt->Print("ZONE: Greenlands \n TIME: 03:22:11 \n ", 0, 0, frm[0], true);

pTxt->Print("Menu: \n   Items\n   Key Items \n   Equip \n * Map \n   Magic \n   Options", 0, 0, frm[1], true);

pTxt->Print("Name: \t Azenris\n Class:\t Mage \n\n HP:\t\t 100 \n MP:\t\t 44 \n\n STR: \t 33 \n MAG: \t 100", 0, 0, frm[2], true);

pTxt->Print("Frame 3", 0, 0, frm[3], true);

/* END TEXT TEST */

Sorry about the formatting, looks better in a proper editor :)

The reason the co-ords are 0, 0 in all the prints is because when using a frame the text position is relative to it. All texts are being printed at the beginning of each frame. In the newer version of Nexlib (not for download yet) you can also specify whether or not you want the text to be absolute or relative (just in case!).

No comments:

Post a Comment