void TextSprite::RecalculateTextData() { CIw2DFont *prevFont = Iw2DGetFont(); if(textFont != null) { Iw2DSetFont(textFont); } else { textFont = prevFont; } int newlineCount = 1; char *checkChar = (char *)this->text.c_str(); while(*checkChar != '\0') { if(*checkChar++ == '\n') { newlineCount++; } } textSize = SCREEN_TO_SUBPIXEL(CIwSVec2(Iw2DGetStringWidth(text.c_str()), textFont->GetHeight() * newlineCount)); UpdatePositionData(); if(prevFont != null) { Iw2DSetFont(prevFont); } }
void DrawBootSequence() { Iw2DSetFont(font); int h = font->GetHeight(); for (unsigned i = 0; i < g_Current_Line; i++) { int w = Iw2DGetStringWidth(g_Bootup_Sequence[i]); Iw2DSetColour(0xffffffff); Iw2DDrawString(g_Bootup_Sequence[i], CIwFVec2(0, i*h), CIwFVec2(w, h), IW_2D_FONT_ALIGN_LEFT, IW_2D_FONT_ALIGN_TOP); } }
void DrawTitleScreen(TitleScreen *title) { int border = 10; Iw2DSetColour(0xffffffff); Iw2DFillRect(title->btnTopLeft, title->btnDim); Iw2DSetColour(0xff000000); Iw2DFillRect(CIwFVec2(title->btnTopLeft.x + border, title->btnTopLeft.y + border), CIwFVec2(title->btnDim.x - 2 * border, title->btnDim.y - 2 * border)); Iw2DSetFont(fontLarge); int fh = fontLarge->GetHeight(); int sw = Iw2DGetStringWidth("P L A Y"); Iw2DSetColour(0xffffffff); Iw2DDrawString("P L A Y", CIwFVec2(title->btnTopLeft.x + border, title->btnTopLeft.y + border), CIwFVec2(title->btnDim.x - 2 * border, title->btnDim.y - 2 * border), IW_2D_FONT_ALIGN_CENTRE, IW_2D_FONT_ALIGN_TOP); Iw2DDrawString("Patriot Missile Defense", CIwFVec2(0.f, 0.f), CIwFVec2(screen.x, screen.y / 2), IW_2D_FONT_ALIGN_CENTRE, IW_2D_FONT_ALIGN_CENTRE); }