~TextManager();
// Base font functions.
- int LoadFont(char* fname);
+ int LoadFont(char* fname, int size);
void Render(char* text);
void Render(char* text, int x, int y);
// Property functions.
// void SetStyle(int style);
- // void SetFontUsed(int font);
+ void SetFontUsed(int font);
void SetColor(int r, int g, int b, int a);
// Complex functions.
int GetXI();
int GetYI();
+ int GetW();
+ int GetH();
+
void Blit();
int* GetHitbox();
exit(-8);
}
- LoadFont((char*)"default.ttf");
+ LoadFont((char*)"default.ttf", 20);
color.r = 255;
color.g = 255;
TTF_Quit();
}
-int TextManager::LoadFont(char* fname) {
+int TextManager::LoadFont(char* fname, int size) {
++fonts_loaded;
fonts = (TTF_Font**)realloc(fonts, sizeof(TTF_Font*) * fonts_loaded);
- if ( !(fonts[fonts_loaded - 1] = TTF_OpenFont(fname, 20) ) ) {
+ if ( !(fonts[fonts_loaded - 1] = TTF_OpenFont(fname, size) ) ) {
printf("Font Open Failed. Load attempt: %s. Msg: %s\n", fname, TTF_GetError());
}
color.b = b;
color.a = a;
}
+
+void TextManager::SetFontUsed(int index)
+{
+ current_font = index;
+}
return this->loc.y;
}
+ // Get Width
+
+ int UDisplayable::GetW() {
+ if (Error)
+ return 0;
+ return this->bmp_w;
+ }
+
+ // Get Height
+
+ int UDisplayable::GetH() {
+ if (Error)
+ return 0;
+ return this->bmp_h;
+ }
+
// Blit to an associated context.
void UDisplayable::Blit() {
GetData()->s_flags = new std::map<std::string, int>();
GetData()->g_flags = new std::map<std::string, int>();
- GetData()->ctx->Text()->Outline(2);
+ // Font
+ GetData()->ctx->Text()->LoadFont((char*)"default.ttf", 24);
+ GetData()->ctx->Text()->SetFontUsed(1);
+
+ GetData()->ctx->Text()->Outline(1);
GetData()->ctx->Text()->SetColor(255,255,255,255);
op_cleartext();
/*
* Implements setimg vnds function.
- * bgload file x y
+ * setimg file x y
*/
void op_setimg(char* file, int* x, int* y) {
// Load displayable.
UDisplayable* fg_add = new UDisplayable(GetData()->ctx, Normal, path);
- fg_add->SetXY(*x, *y);
+ // Centered NDS adapted
+ double adp_x = ((double)x[0]) * (GetData()->screen_w / 256);
+ double adp_y = ((double)y[0]) * (GetData()->screen_h / 192);
+ fg_add->SetXY((int)adp_x, (int)adp_y);
+
+ // Raw
+ // fg_add->SetXY(x[0], y[0]);
fg_add->Blit();