void TB_SaveSelect::DrawProfile(int x, int y, int index) { Profile *p = &fProfiles[index]; const int w = fCoords.w - 33; int sidewd = sprites[SPR_SAVESELECTOR_SIDES].w; int repeatwd = w - (sidewd * 2); int frame = (index == fCurSel) ? 0 : 1; draw_sprite(x, y, SPR_SAVESELECTOR_SIDES, frame, LEFT); draw_sprite_repeating_x(x+sidewd, y, SPR_SAVESELECTOR_MIDDLE, frame, repeatwd); draw_sprite(x+sidewd+repeatwd, y, SPR_SAVESELECTOR_SIDES, frame, RIGHT); y += 4; const int FONT_SPACING = 5; if (fHaveProfile[index]) { const char *stage = map_get_stage_name(p->stage); font_draw(x+8, y-1, stage, FONT_SPACING); // draw health. DrawHealth(x+w, y, p); } else if (fCurSel == index) { const char *str = "available"; int fx = (w / 2) - (GetFontWidth(str, FONT_SPACING) / 2); font_draw(x+fx, y-1, str, FONT_SPACING); } }
bool ms_init(int return_to_mode) { memset(&ms, 0, sizeof(ms)); ms.return_gm = return_to_mode; ms.lastbuttondown = true; ms.w = map.xsize; ms.h = map.ysize; // create the surface ms.sfc = new NXSurface(ms.w, ms.h); ms.sfc->FillRect(0, 0, ms.w, ms.h, DK_BLUE); ms.x = (Graphics::SCREEN_WIDTH / 2) - (ms.w / 2); ms.y = (Graphics::SCREEN_HEIGHT / 2) - (ms.h / 2); // where will we put the dot? ms.px = ms.x + ((player->x >> CSF) / TILE_W); ms.py = ms.y + ((player->y >> CSF) / TILE_H); ms.bannertext = stages[game.curmap].stagename; ms.textx = (Graphics::SCREEN_WIDTH / 2) - (GetFontWidth(ms.bannertext, 0) / 2); ms.texty = BANNER_TOP+3; return 0; }
void TTFFont::DrawString( Renderer &r, int X, int Y, std::string Text, int Alignment ) { assert(0 && "NOT IMPLEMENTED"); #if 0 int xpos = X; int textlen = 0; if( Alignment != APOCFONT_ALIGN_LEFT ) { textlen = GetFontWidth( Text ); switch( Alignment ) { case APOCFONT_ALIGN_CENTRE: xpos -= textlen / 2; break; case APOCFONT_ALIGN_RIGHT: xpos -= textlen; break; } } al_draw_text( fontobject, al_map_rgb( 255, 255, 255 ), xpos, Y, 0, Text.c_str() ); #endif }
static void draw_title() { // background is dk grey, not pure black ClearScreen(0x20, 0x20, 0x20); // top logo int tx = (SCREEN_WIDTH / 2) - (sprites[SPR_TITLE].w / 2) - 2; draw_sprite(tx, 40, SPR_TITLE); // draw menu int cx = (SCREEN_WIDTH / 2) - (sprites[SPR_MENU].w / 2) - 8; int cy = (SCREEN_HEIGHT / 2) + 8; for(int i=0;i<sprites[SPR_MENU].nframes;i++) { draw_sprite(cx, cy, SPR_MENU, i); if (i == title.cursel) { draw_sprite(cx - 16, cy - 1, title.sprite, title.selframe); } cy += (sprites[SPR_MENU].h + 4); } // animate character if (++title.seltimer > 8) { title.seltimer = 0; if (++title.selframe >= sprites[title.sprite].nframes) title.selframe = 0; } // accreditation cx = (SCREEN_WIDTH / 2) - (sprites[SPR_PIXEL_FOREVER].w / 2); int acc_y = SCREEN_HEIGHT - 48; draw_sprite(cx, acc_y, SPR_PIXEL_FOREVER); // version static const char *VERSION = "NXEngine v. 1.0.0.4"; static const int SPACING = 5; int wd = GetFontWidth(VERSION, SPACING); cx = (SCREEN_WIDTH / 2) - (wd / 2); font_draw(cx, acc_y + sprites[SPR_PIXEL_FOREVER].h + 4, VERSION, SPACING); // draw Nikumaru display if (title.besttime != 0xffffffff) niku_draw(title.besttime, true); }
void update_fps() { fps_so_far++; if ((SDL_GetTicks() - fpstimer) >= 500) { fpstimer = SDL_GetTicks(); fps = (fps_so_far << 1); fps_so_far = 0; } char fpstext[64]; sprintf(fpstext, "%d fps", fps); int x = (SCREEN_WIDTH - 4) - GetFontWidth(fpstext, 0, true); font_draw_shaded(x, 4, fpstext, 0, &greenfont); }
void TTFFont::DrawString( int X, int Y, std::string Text, FontHAlign::FontHorizontalAlignment Alignment, ALLEGRO_COLOR Colour ) { int xpos = X; int textlen = 0; if( Alignment != FontHAlign::LEFT ) { textlen = GetFontWidth( Text ); switch( Alignment ) { case FontHAlign::CENTRE: xpos -= textlen / 2; break; case FontHAlign::RIGHT: xpos -= textlen; break; } } al_draw_text( fontobject, Colour, xpos, Y, 0, Text.c_str() ); }
static void draw_title() { // background is dk grey, not pure black ClearScreen(0x20, 0x20, 0x20); // top logo int tx = (Graphics::SCREEN_WIDTH / 2) - (sprites[SPR_TITLE].w / 2) - 2; draw_sprite(tx, 40, SPR_TITLE); // draw menu int cx = (Graphics::SCREEN_WIDTH / 2) - (sprites[SPR_MENU].w / 2) - 8; int cy = (Graphics::SCREEN_HEIGHT / 2) - 8; for(int i=0;i<sprites[SPR_MENU].nframes;i++) { draw_sprite(cx, cy, SPR_MENU, i); if (i == title.cursel) { draw_sprite(cx - 16, cy - 1, title.sprite, title.selframe); } //RectI r = Sprites::get_sprite_rect(cx, cy, SPR_MENU, i); //Graphics::DrawRect(r.x, r.y, r.x + r.w, r.y + r.h, 255,255,255); cy += (sprites[SPR_MENU].h + 18); } // animate character if (++title.seltimer > 8) { title.seltimer = 0; if (++title.selframe >= sprites[title.sprite].nframes) title.selframe = 0; } // accreditation cx = (Graphics::SCREEN_WIDTH / 2) - (sprites[SPR_PIXEL_FOREVER].w / 2); int acc_y = Graphics::SCREEN_HEIGHT - 48; draw_sprite(cx, acc_y, SPR_PIXEL_FOREVER); // version static const char *VERSION = "NXEngine v. 1.0.0.4"; static const int SPACING = 5; int wd = GetFontWidth(VERSION, SPACING); cx = (Graphics::SCREEN_WIDTH / 2) - (wd / 2); font_draw(cx, acc_y + sprites[SPR_PIXEL_FOREVER].h + 4, VERSION, SPACING); // draw Nikumaru display if (title.besttime != 0xffffffff) niku_draw(title.besttime, true); // options { const char *str = "F3:Options"; cx = (Graphics::SCREEN_WIDTH / 2) - (GetFontWidth(str, 0) / 2) - 4; cy = (Graphics::SCREEN_HEIGHT - 8) - GetFontHeight(); int f3wd = font_draw(cx, cy, "F3", 0); font_draw(cx + f3wd, cy, ":Options", 0, &bluefont); #ifdef CONFIG_USE_TAPS RectI r = RectI(cx, cy, GetFontWidth(str, 0), GetFontHeight()); debug_absbox(r.x, r.y, r.x + r.w, r.y + r.h, 255, 255, 255); if (VJoy::ModeAware::wasTap(r)) { game.pause(GP_OPTIONS); } #endif } }
void Credits::RunNextCommand() { CredCommand cmd; if (script.ReadCommand(&cmd)) { console.Print("script.ReadCommand failed: credits terminated"); roll_running = false; return; } cmd.DumpContents(); switch(cmd.type) { case CC_TEXT: { CredLine *line = NewLine(); maxcpy(line->text, cmd.text, sizeof(line->text)); line->image = cmd.parm; line->x = xoffset; line->y = spawn_y; // the last line is supposed to be centered--slightly // varying font sizes can lead to it being a little bit off if (strstr(line->text, "The End")) { line->x = (SCREEN_WIDTH / 2) - (GetFontWidth(line->text, TEXT_SPACING) / 2); } spawn_y += 1; lines_out++; } break; case CC_BLANK_SPACE: spawn_y += cmd.parm / 2; break; case CC_SET_XOFF: xoffset = cmd.parm; break; case CC_FLAGJUMP: if (game.flags[cmd.parm]) Jump(cmd.parm2); break; case CC_JUMP: Jump(cmd.parm); break; case CC_LABEL: break; case CC_MUSIC: music(cmd.parm); break; case CC_FADE_MUSIC: org_fade(); break; case CC_END: roll_running = false; break; default: console.Print("Unhandled command '%c'; credits terminated", cmd.type); roll_running = false; break; } }