void frontnet_draw_small_scroll_selection_box(struct GuiButton *gbtn, long font_idx, const char *text) { struct TbSprite *spr; int pos_x, pos_y; pos_x = gbtn->scr_pos_x; pos_y = gbtn->scr_pos_y; spr = &frontend_sprite[55]; int fs_units_per_px; fs_units_per_px = gbtn->height * 16 / spr->SHeight; LbSpriteDrawResized(pos_x, pos_y, fs_units_per_px, spr); pos_x += spr->SWidth * fs_units_per_px / 16; spr = &frontend_sprite[56]; LbSpriteDrawResized(pos_x, pos_y, fs_units_per_px, spr); pos_x += spr->SWidth * fs_units_per_px / 16; LbSpriteDrawResized(pos_x, pos_y, fs_units_per_px, spr); pos_x += spr->SWidth * fs_units_per_px / 16; spr = &frontend_sprite[60]; LbSpriteDrawResized(pos_x, pos_y, fs_units_per_px, spr); if (text != NULL) { LbTextSetFont(frontend_font[font_idx]); lbDisplay.DrawFlags = 0; int tx_units_per_px; tx_units_per_px = (gbtn->height*13/14) * 16 / LbTextLineHeight(); int height; height = LbTextLineHeight() * tx_units_per_px / 16; LbTextSetWindow(gbtn->scr_pos_x + 13*fs_units_per_px/16, gbtn->scr_pos_y, gbtn->width - 26*fs_units_per_px/16, height); LbTextDrawResized(0, 0, tx_units_per_px, text); } }
void message_draw(void) { int i,h; long x,y; SYNCDBG(7,"Starting"); LbTextSetFont(winfont); int tx_units_per_px; tx_units_per_px = (22 * units_per_pixel) / LbTextLineHeight(); int ps_units_per_px; { struct TbSprite *spr; spr = &gui_panel_sprites[488]; ps_units_per_px = (22 * units_per_pixel) / spr->SHeight; } h = LbTextLineHeight(); x = 148*units_per_pixel/16; y = 28*units_per_pixel/16; for (i=0; i < game.active_messages_count; i++) { LbTextSetWindow(0, 0, MyScreenWidth, MyScreenHeight); set_flag_word(&lbDisplay.DrawFlags,Lb_TEXT_ONE_COLOR,false); LbTextDrawResized(x+32*units_per_pixel/16, y, tx_units_per_px, game.messages[i].text); draw_gui_panel_sprite_left(x, y, ps_units_per_px, 488+game.messages[i].plyr_idx); y += h*units_per_pixel/16; } }
void frontnet_draw_net_session_players(struct GuiButton *gbtn) { int i; i = frontend_button_caption_font(gbtn, 0); lbDisplay.DrawFlags = 0; LbTextSetFont(frontend_font[i]); int tx_units_per_px; tx_units_per_px = gbtn->height * 16 / (2*LbTextLineHeight()); const struct TbSprite *spr; spr = &frontend_sprite[21]; int fs_units_per_px; fs_units_per_px = gbtn->height * 16 / (2*(spr->SHeight*13/8)); int height; height = LbTextLineHeight() * tx_units_per_px / 16; long netplyr_idx; int shift_y; netplyr_idx = net_player_scroll_offset; for (shift_y=0; shift_y < gbtn->height; shift_y += height, netplyr_idx++) { const char *text; text = net_player[netplyr_idx].name; if (netplyr_idx >= net_number_of_enum_players) break; spr = &frontend_sprite[21+netplyr_idx]; i = height - spr->SHeight * fs_units_per_px / 16; LbSpriteDrawResized(gbtn->scr_pos_x, gbtn->scr_pos_y + shift_y + abs(i)/2, fs_units_per_px, spr); LbTextSetWindow(gbtn->scr_pos_x, shift_y + gbtn->scr_pos_y, gbtn->width - spr->SWidth * fs_units_per_px / 16, height); LbTextDrawResized(spr->SWidth * fs_units_per_px / 16, 0, tx_units_per_px, text); } }
/** * Returns box option under given position. * Requires text font to be set properly before running. */ struct GuiBoxOption *gui_get_box_option_point_over(struct GuiBox *gbox, long x, long y) { long sx,sy,lnheight; long width,height; struct GuiBoxOption *gboptn; sx = gbox->pos_x + 8; sy = gbox->pos_y + 8; gboptn = gbox->optn_list; lnheight = LbTextLineHeight()*((long)pixel_size) + 2; while (gboptn->label[0] != '!') { height = LbTextStringHeight(gboptn->label)*((long)pixel_size); if ((y >= sy) && (y < sy+height)) { width = LbTextStringWidth(gboptn->label)*((long)pixel_size); if ((x >= sx) && (x < sx+width)) { if ((gboptn->numfield_4 == 2) || (gboptn->field_26 == 0)) return NULL; return gboptn; } } gboptn++; sy += lnheight; } return NULL; }
void draw_resurrect_creature(struct GuiButton *gbtn) { unsigned short flg_mem; flg_mem = lbDisplay.DrawFlags; lbDisplay.DrawFlags = Lb_SPRITE_TRANSPAR4; LbDrawBox(gbtn->scr_pos_x, gbtn->scr_pos_y, gbtn->width, gbtn->height, 0); LbTextSetFont(winfont); LbTextSetWindow(gbtn->scr_pos_x, gbtn->scr_pos_y, gbtn->width, gbtn->height); struct Dungeon *dungeon; dungeon = get_my_dungeon(); int i; i = selected_resurrect_creature(dungeon, gbtn); int tx_units_per_px; tx_units_per_px = ((gbtn->height*22/26) * 16) / LbTextLineHeight(); if (i != -1) { struct CreatureStorage *cstore; cstore = &dungeon->dead_creatures[i]; struct CreatureData *crdata; crdata = creature_data_get(cstore->model); lbDisplay.DrawFlags = Lb_TEXT_HALIGN_LEFT; LbTextDrawResizedFmt(0, 0, tx_units_per_px, " %s", get_string(crdata->namestr_idx)); lbDisplay.DrawFlags = Lb_TEXT_HALIGN_RIGHT; LbTextDrawResizedFmt(0, 0, tx_units_per_px, "%s %d ", get_string(GUIStr_MnuLevel), (int)(cstore->explevel + 1)); } lbDisplay.DrawFlags = flg_mem; }
void frontcredits_draw(void) { struct CreditsItem *credit; TbBool did_draw; int fontid; long i; long h; const char *text; credits_offset -= credits_scroll_speed; frontend_copy_background(); lbDisplay.DrawFlags = Lb_SPRITE_OUTLINE | Lb_TEXT_HALIGN_CENTER; LbTextSetWindow(0, 0, lbDisplay.PhysicalScreenWidth, lbDisplay.PhysicalScreenHeight); fontid = 1; LbTextSetFont(frontend_font[fontid]); h = credits_offset; did_draw = h > 0; for (i = 0; campaign.credits[i].kind != CIK_None; i++) { if (h >= lbDisplay.PhysicalScreenHeight) break; credit = &campaign.credits[i]; if (credit->font != fontid) { fontid = credit->font; LbTextSetFont(frontend_font[fontid]); } int ln_height; ln_height = -LbTextLineHeight() * units_per_pixel / 16; if (h > ln_height) { switch (credit->kind) { case CIK_GStringId: text = gui_string(credit->num); break; case CIK_CStringId: text = cmpgn_string(credit->num); break; case CIK_DirectText: text = credit->str; break; default: text = ""; break; } LbTextDrawResized(0, h, units_per_pixel, text); did_draw = 1; } h += ln_height + 2 * units_per_pixel / 16; } if (!did_draw) { credits_end = 1; credits_offset = lbDisplay.PhysicalScreenHeight; } }
void frontnet_draw_messages(struct GuiButton *gbtn) { int font_idx; font_idx = frontend_button_caption_font(gbtn, 0); LbTextSetFont(frontend_font[font_idx]); lbDisplay.DrawFlags = 0; // While setting scale, aim for 4 lines of text int tx_units_per_px; tx_units_per_px = gbtn->height * 16 / (4*LbTextLineHeight()); struct TbSprite *spr; spr = &frontend_sprite[21]; int fs_units_per_px; fs_units_per_px = gbtn->height * 16 / (4*(spr->SHeight*13/8)); int font_height; font_height = LbTextLineHeight() * tx_units_per_px / 16; int y; y = 0; int netmsg_id; for (netmsg_id=net_message_scroll_offset; netmsg_id < net_number_of_messages; netmsg_id++) { if (y + font_height/2 > gbtn->height) break; struct NetMessage *nmsg; nmsg = &net_message[netmsg_id]; int num_active; num_active = 0; int i; for (i = nmsg->plyr_idx; i > 0; i--) { if ( net_player_info[i].active) num_active++; } spr = &frontend_sprite[21+num_active]; i = font_height - spr->SHeight * fs_units_per_px / 16; LbSpriteDrawResized(gbtn->scr_pos_x, y + gbtn->scr_pos_y + (i >> 1), fs_units_per_px, spr); LbTextSetWindow(gbtn->scr_pos_x, y + gbtn->scr_pos_y, gbtn->width, min(font_height, gbtn->height-y)); LbTextDrawResized(spr->SWidth * fs_units_per_px / 16, 0, tx_units_per_px, nmsg->text); y += font_height; } }
void frontend_draw_load_game_button(struct GuiButton *gbtn) { int i; i = frontend_load_game_button_to_index(gbtn); if (i < 0) return; // Select font to draw int font_idx; font_idx = frontend_button_caption_font(gbtn,frontend_mouse_over_button); LbTextSetFont(frontend_font[font_idx]); lbDisplay.DrawFlags = Lb_TEXT_HALIGN_LEFT; // Set drawing window and draw the text int tx_units_per_px; tx_units_per_px = (gbtn->height*13/11) * 16 / LbTextLineHeight(); int height; height = LbTextLineHeight() * tx_units_per_px / 16; LbTextSetWindow(gbtn->scr_pos_x, gbtn->scr_pos_y, gbtn->width, height); LbTextDrawResized(0, 0, tx_units_per_px, save_game_catalogue[i].textname); }
void frontstory_draw(void) { frontend_copy_background(); LbTextSetWindow(70*units_per_pixel/16, 70*units_per_pixel/16, (640-2*70)*units_per_pixel/16, (480-2*70)*units_per_pixel/16); LbTextSetFont(frontstory_font); lbDisplay.DrawFlags = Lb_TEXT_HALIGN_CENTER; int tx_units_per_px; tx_units_per_px = (26 * units_per_pixel) / LbTextLineHeight(); LbTextDrawResized(0, 0, tx_units_per_px, get_string(frontstory_text_no)); }
void frontnet_draw_session_button(struct GuiButton *gbtn) { long sessionIndex; long febtn_idx; long height; febtn_idx = (long)gbtn->content; sessionIndex = net_session_scroll_offset + febtn_idx - 45; if ((sessionIndex < 0) || (sessionIndex >= net_number_of_sessions)) return; int font_idx; font_idx = frontend_button_caption_font(gbtn,frontend_mouse_over_button); LbTextSetFont(frontend_font[font_idx]); lbDisplay.DrawFlags = 0; int tx_units_per_px; tx_units_per_px = gbtn->height * 16 / LbTextLineHeight(); height = LbTextLineHeight() * tx_units_per_px / 16; LbTextSetWindow(gbtn->scr_pos_x, gbtn->scr_pos_y, gbtn->width, height); LbTextDrawResized(0, 0, tx_units_per_px, net_session[sessionIndex]->text); }
void frontnet_draw_service_button(struct GuiButton *gbtn) { int srvidx; // Find and verify selected network service srvidx = (long)gbtn->content + net_service_scroll_offset - 45; if (srvidx >= net_number_of_services) return; // Select font to draw int font_idx; font_idx = frontend_button_caption_font(gbtn,frontend_mouse_over_button); LbTextSetFont(frontend_font[font_idx]); lbDisplay.DrawFlags = Lb_TEXT_HALIGN_LEFT; // Set drawing window and draw the text int tx_units_per_px; tx_units_per_px = gbtn->height * 16 / LbTextLineHeight(); int height; height = LbTextLineHeight() * tx_units_per_px / 16; LbTextSetWindow(gbtn->scr_pos_x, gbtn->scr_pos_y, gbtn->width, height); LbTextDrawResized(0, 0, tx_units_per_px, net_service[srvidx]); }
void frontcredits_input(void) { int fontid; credits_scroll_speed = 1 * units_per_pixel / 16; fontid = 1; int speed; if ( lbKeyOn[KC_DOWN] ) { LbTextSetFont(frontend_font[fontid]); speed = LbTextLineHeight() * units_per_pixel / 16; credits_scroll_speed = speed; } else if ((lbKeyOn[KC_UP]) && (credits_offset <= 0)) { LbTextSetFont(frontend_font[fontid]); speed = -LbTextLineHeight() * units_per_pixel / 16; if (speed <= credits_offset) speed = credits_offset; credits_scroll_speed = speed; } }
void draw_out_of_sync_box(long a1, long a2, long box_width) { long min_width,max_width; long ornate_width,ornate_height; long x,y; long text_x,text_y,text_h; min_width = 2*a1; max_width = 2*a2; if (min_width > max_width) { min_width = max_width; } if (min_width < 0) { min_width = 0; } int units_per_px; units_per_px = units_per_pixel; if (LbScreenLock() == Lb_SUCCESS) { ornate_width = 200*units_per_px/16; ornate_height = 100*units_per_px/16; x = box_width + (MyScreenWidth-box_width-ornate_width) / 2; y = (MyScreenHeight-ornate_height) / 2; draw_ornate_slab64k(x, y, units_per_px, ornate_width, ornate_height); LbTextSetFont(winfont); lbDisplay.DrawFlags = Lb_TEXT_HALIGN_CENTER; LbTextSetWindow(x, y, ornate_width, ornate_height); int tx_units_per_px; tx_units_per_px = (22 * units_per_px) / LbTextLineHeight(); text_h = LbTextLineHeight()*tx_units_per_px/16; text_x = x + 100*units_per_px/16 - max_width; text_y = y + 58*units_per_px/16; LbTextDrawResized(0, 50*units_per_px/16 - text_h, tx_units_per_px, get_string(GUIStr_NetResyncing)); LbDrawBox(text_x, text_y, 2*max_width, 16*units_per_px/16, 0); LbDrawBox(text_x, text_y, 2*min_width, 16*units_per_px/16, 133); LbScreenUnlock(); LbScreenRender(); } }
long gui_calculate_box_height(struct GuiBox *gbox) { struct GuiBoxOption *goptn; int i; i = 0; goptn = gbox->optn_list; while (goptn->label[0] != '!') { i++; goptn++; } return i*(pixel_size*LbTextLineHeight()+2) + 16; }
void frontnet_draw_comport_button(struct GuiButton *gbtn) { int i; int febtn_idx; febtn_idx = (long)gbtn->content; i = net_comport_scroll_offset + febtn_idx - 45; if (i < number_of_comports) { int font_idx; font_idx = frontend_button_caption_font(gbtn,frontend_mouse_over_button); LbTextSetFont(frontend_font[font_idx]); lbDisplay.DrawFlags = 0; const char *text; text = get_net_comport_text(i); int tx_units_per_px; tx_units_per_px = (gbtn->height*13/14) * 16 / LbTextLineHeight(); int height; height = LbTextLineHeight() * tx_units_per_px / 16; LbTextSetWindow(gbtn->scr_pos_x, gbtn->scr_pos_y, gbtn->width, height); LbTextDrawResized(0, 0, tx_units_per_px, text); } }
TbBool draw_text_box(const char *text) { long spritesy,spritesx; long box_width,box_height; long startx,starty; long n; LbTextSetFont(frontend_font[1]); n = LbTextStringWidth(text); if (n < (4*108)) { spritesy = 1; spritesx = n / 108; } else { spritesx = 4; spritesy = n / (3*108); } if (spritesy > 4) { ERRORLOG("Text too long for error box"); } if (spritesx < 2) { spritesx = 2; } else if (spritesx > 4) { spritesx = 4; } box_width = (108 * spritesx + 18) * units_per_pixel / 16; box_height = 92 * units_per_pixel / 16; startx = (lbDisplay.PhysicalScreenWidth - box_width) / 2; starty = (lbDisplay.PhysicalScreenHeight - box_height) / 2; draw_message_box_at(startx, starty, box_width, box_height, spritesx, spritesy); // Draw the text inside box lbDisplay.DrawFlags = Lb_TEXT_HALIGN_CENTER; int tx_units_per_px; tx_units_per_px = ((box_height/4)*13/11) * 16 / LbTextLineHeight(); LbTextSetWindow(startx, starty, box_width, box_height); n = LbTextLineHeight() * tx_units_per_px / 16; return LbTextDrawResized(0, (box_height - spritesy * n) / 2, tx_units_per_px, text); }
void frontnet_draw_session_selected(struct GuiButton *gbtn) { //_DK_frontnet_draw_session_selected(gbtn); struct TbSprite *spr; long pos_x, pos_y; int i; pos_x = gbtn->scr_pos_x; pos_y = gbtn->scr_pos_y; int fs_units_per_px; fs_units_per_px = simple_frontend_sprite_height_units_per_px(gbtn, 56, 100); spr = &frontend_sprite[55]; for (i=0; i < 6; i++) { LbSpriteDrawResized(pos_x, pos_y, fs_units_per_px, spr); pos_x += spr->SWidth * fs_units_per_px / 16; spr++; } if (net_session_index_active >= 0) { const char *text; text = net_session[net_session_index_active]->text; i = frontend_button_caption_font(gbtn, 0); if (text != NULL) { lbDisplay.DrawFlags = 0; LbTextSetFont(frontend_font[i]); // Set drawing window and draw the text int tx_units_per_px; tx_units_per_px = (gbtn->height*13/14) * 16 / LbTextLineHeight(); int h; h = LbTextLineHeight()*tx_units_per_px/16; LbTextSetWindow(gbtn->scr_pos_x + 13*fs_units_per_px/16, gbtn->scr_pos_y, gbtn->width - 26*fs_units_per_px/16, h); LbTextDrawResized(0, 0, tx_units_per_px, text); } } }
void frontend_draw_invert_mouse(struct GuiButton *gbtn) { int font_idx; font_idx = frontend_button_caption_font(gbtn,frontend_mouse_over_button); LbTextSetFont(frontend_font[font_idx]); LbTextSetWindow(gbtn->scr_pos_x, gbtn->scr_pos_y, gbtn->width, gbtn->height); int tx_units_per_px; tx_units_per_px = gbtn->height * 16 / LbTextLineHeight(); const char *text; if (settings.first_person_move_invert) { text = get_string(GUIStr_On); } else { text = get_string(GUIStr_Off); } LbTextDrawResized(0, 0, tx_units_per_px, text); }
void frontbirthday_draw(void) { frontend_copy_background(); LbTextSetWindow(70, 70, 500, 340); LbTextSetFont(frontstory_font); lbDisplay.DrawFlags = Lb_SPRITE_OUTLINE; const char *name=get_team_birthday(); if ( name != NULL ) { unsigned short line_pos; line_pos = LbTextLineHeight(); LbTextDraw(0, 170-line_pos, get_string(GUIStr_HappyBirthday)); LbTextDraw(0, 170, name); } else { frontend_set_state(FeSt_INTRO); } }
void draw_overlay_compass(long base_x, long base_y) { unsigned short flg_mem; flg_mem = lbDisplay.DrawFlags; LbTextSetFont(winfont); lbDisplay.DrawFlags |= Lb_SPRITE_TRANSPAR4; LbTextSetWindow(0, 0, MyScreenWidth, MyScreenHeight); int units_per_px; units_per_px = (16*status_panel_width + 140/2) / 140; int tx_units_per_px; tx_units_per_px = (22 * units_per_px) / LbTextLineHeight(); int w,h; w = (LbSprFontCharWidth(lbFontPtr,'/')*tx_units_per_px/16) / 2; h = (LbSprFontCharHeight(lbFontPtr,'/')*tx_units_per_px/16) / 2 + 2*units_per_px/16; struct PlayerInfo *player; player = get_my_player(); const struct Camera *cam; cam = player->acamera; int center_x, center_y; int shift_x, shift_y; center_x = base_x*units_per_px/16 + MapDiagonalLength/2; center_y = base_y*units_per_px/16 + MapDiagonalLength/2; shift_x = (-(MapDiagonalLength*7/16) * LbSinL(cam->orient_a)) >> LbFPMath_TrigmBits; shift_y = (-(MapDiagonalLength*7/16) * LbCosL(cam->orient_a)) >> LbFPMath_TrigmBits; if (LbScreenIsLocked()) { LbTextDrawResized(center_x + shift_x - w, center_y + shift_y - h, tx_units_per_px, get_string(GUIStr_MapN)); } shift_x = ( (MapDiagonalLength*7/16) * LbSinL(cam->orient_a)) >> LbFPMath_TrigmBits; shift_y = ( (MapDiagonalLength*7/16) * LbCosL(cam->orient_a)) >> LbFPMath_TrigmBits; if (LbScreenIsLocked()) { LbTextDrawResized(center_x + shift_x - w, center_y + shift_y - h, tx_units_per_px, get_string(GUIStr_MapS)); } shift_x = ( (MapDiagonalLength*7/16) * LbCosL(cam->orient_a)) >> LbFPMath_TrigmBits; shift_y = (-(MapDiagonalLength*7/16) * LbSinL(cam->orient_a)) >> LbFPMath_TrigmBits; if (LbScreenIsLocked()) { LbTextDrawResized(center_x + shift_x - w, center_y + shift_y - h, tx_units_per_px, get_string(GUIStr_MapE)); } shift_x = (-(MapDiagonalLength*7/16) * LbCosL(cam->orient_a)) >> LbFPMath_TrigmBits; shift_y = ( (MapDiagonalLength*7/16) * LbSinL(cam->orient_a)) >> LbFPMath_TrigmBits; if (LbScreenIsLocked()) { LbTextDrawResized(center_x + shift_x - w, center_y + shift_y - h, tx_units_per_px, get_string(GUIStr_MapW)); } lbDisplay.DrawFlags = flg_mem; }
void draw_overlay_compass(long base_x, long base_y) { unsigned short flg_mem; flg_mem = lbDisplay.DrawFlags; LbTextSetFont(winfont); lbDisplay.DrawFlags |= Lb_SPRITE_TRANSPAR4; LbTextSetWindow(0, 0, MyScreenWidth, MyScreenHeight); int units_per_px; units_per_px = (16*status_panel_width + 70) / 140; int tx_units_per_px; tx_units_per_px = (22 * units_per_px) / LbTextLineHeight(); int w,h; w = (LbSprFontCharWidth(lbFontPtr,'/')*tx_units_per_px/16) / 2; h = (LbSprFontCharHeight(lbFontPtr,'/')*tx_units_per_px/16) / 2 + 2*units_per_px/16; struct PlayerInfo *player; player = get_my_player(); struct Camera *cam; cam = player->acamera; int center_x, center_y; int shift_x, shift_y; center_x = base_x*units_per_px/16 + PANNEL_MAP_RADIUS*units_per_px/16; center_y = base_y*units_per_px/16 + PANNEL_MAP_RADIUS*units_per_px/16; shift_x = ((-(PANNEL_MAP_RADIUS*7/8)*units_per_px/16) * LbSinL(cam->orient_a)) >> LbFPMath_TrigmBits; shift_y = ((-(PANNEL_MAP_RADIUS*7/8)*units_per_px/16) * LbCosL(cam->orient_a)) >> LbFPMath_TrigmBits; if (LbScreenIsLocked()) { LbTextDrawResized(center_x + shift_x - w, center_y + shift_y - h, tx_units_per_px, gui_strings[877]); } shift_x = (( (PANNEL_MAP_RADIUS*7/8)*units_per_px/16) * LbSinL(cam->orient_a)) >> LbFPMath_TrigmBits; shift_y = (( (PANNEL_MAP_RADIUS*7/8)*units_per_px/16) * LbCosL(cam->orient_a)) >> LbFPMath_TrigmBits; if (LbScreenIsLocked()) { LbTextDrawResized(center_x + shift_x - w, center_y + shift_y - h, tx_units_per_px, gui_strings[879]); } shift_x = (( (PANNEL_MAP_RADIUS*7/8)*units_per_px/16) * LbCosL(cam->orient_a)) >> LbFPMath_TrigmBits; shift_y = ((-(PANNEL_MAP_RADIUS*7/8)*units_per_px/16) * LbSinL(cam->orient_a)) >> LbFPMath_TrigmBits; if (LbScreenIsLocked()) { LbTextDrawResized(center_x + shift_x - w, center_y + shift_y - h, tx_units_per_px, gui_strings[878]); } shift_x = ((-(PANNEL_MAP_RADIUS*7/8)*units_per_px/16) * LbCosL(cam->orient_a)) >> LbFPMath_TrigmBits; shift_y = (( (PANNEL_MAP_RADIUS*7/8)*units_per_px/16) * LbSinL(cam->orient_a)) >> LbFPMath_TrigmBits; if (LbScreenIsLocked()) { LbTextDrawResized(center_x + shift_x - w, center_y + shift_y - h, tx_units_per_px, gui_strings[880]); } lbDisplay.DrawFlags = flg_mem; }
/** Draws a string on GUI button. * Note that the source text buffer may be damaged by this function. * @param gbtn Button to draw text on. * @param base_width Width of the button before scaling. * @param text Text to be displayed. */ void draw_button_string(struct GuiButton *gbtn, int base_width, const char *text) { unsigned long flgmem; static unsigned char cursor_type = 0; static char dtext[TEXT_BUFFER_LENGTH]; flgmem = lbDisplay.DrawFlags; long cursor_pos = -1; LbStringCopy(dtext,text,TEXT_BUFFER_LENGTH); if ((gbtn->button_type == LbBtnType_EditBox) && (gbtn == input_button)) { cursor_type++; if ((cursor_type & 0x02) == 0) cursor_pos = input_field_pos; LbLocTextStringConcat(dtext, " ", TEXT_BUFFER_LENGTH); lbDisplay.DrawColour = LbTextGetFontFaceColor(); lbDisplayEx.ShadowColour = LbTextGetFontBackColor(); } LbTextSetJustifyWindow(gbtn->scr_pos_x, gbtn->scr_pos_y, gbtn->width); LbTextSetClipWindow(gbtn->scr_pos_x, gbtn->scr_pos_y, gbtn->width, gbtn->height); lbDisplay.DrawFlags = Lb_TEXT_HALIGN_CENTER;// | Lb_TEXT_UNDERLNSHADOW; if (cursor_pos >= 0) { // Mind the order, 'cause inserting makes positions shift LbLocTextStringInsert(dtext, "\x0B", cursor_pos+1, TEXT_BUFFER_LENGTH); LbLocTextStringInsert(dtext, "\x0B", cursor_pos, TEXT_BUFFER_LENGTH); } int units_per_px; units_per_px = (gbtn->width * 16 + base_width/2) / base_width; int tx_units_per_px; tx_units_per_px = units_per_px*22/LbTextLineHeight(); unsigned long w,h; w = 4 * units_per_px / 16; h = (gbtn->height - text_string_height(tx_units_per_px, dtext))/2 - 3*units_per_px/16; LbTextDrawResized(w, h, tx_units_per_px, dtext); LbTextSetJustifyWindow(0, 0, LbGraphicsScreenWidth()); LbTextSetClipWindow(0/pixel_size, 0/pixel_size, MyScreenWidth/pixel_size, MyScreenHeight/pixel_size); LbTextSetWindow(0/pixel_size, 0/pixel_size, MyScreenWidth/pixel_size, MyScreenHeight/pixel_size); lbDisplay.DrawFlags = flgmem; }
void draw_transfer_creature(struct GuiButton *gbtn) { unsigned long flgmem; if (gbtn == NULL) return; SYNCDBG(7,"Starting"); flgmem = lbDisplay.DrawFlags; lbDisplay.DrawFlags = Lb_SPRITE_TRANSPAR4; LbTextSetFont(winfont); LbDrawBox(gbtn->scr_pos_x, gbtn->scr_pos_y, gbtn->width, gbtn->height, 0); // The 0 means black color LbTextSetWindow(gbtn->scr_pos_x, gbtn->scr_pos_y, gbtn->width, gbtn->height); struct Dungeon *dungeon; dungeon = get_my_dungeon(); struct Thing *thing; thing = INVALID_THING; int listitm_idx; listitm_idx = selected_transfer_creature(dungeon, gbtn); int tx_units_per_px; tx_units_per_px = ((gbtn->height*22/26) * 16) / LbTextLineHeight(); if (listitm_idx != -1) { thing = get_player_list_nth_creature_of_model(dungeon->creatr_list_start, 0, listitm_idx); } if (!thing_is_invalid(thing)) { const struct CreatureControl *cctrl; cctrl = creature_control_get_from_thing(thing); const struct CreatureData *crdata; crdata = creature_data_get_from_thing(thing); lbDisplay.DrawFlags = Lb_TEXT_HALIGN_LEFT; LbTextDrawResizedFmt(0, 0, tx_units_per_px, " %s", get_string(crdata->namestr_idx)); lbDisplay.DrawFlags = Lb_TEXT_HALIGN_RIGHT; LbTextDrawResizedFmt(0, 0, tx_units_per_px, "%s %d ", get_string(GUIStr_MnuLevel), (int)(cctrl->explevel+1)); } lbDisplay.DrawFlags = flgmem; }
void gui_draw_box(struct GuiBox *gbox) { SYNCDBG(6,"Drawing box, first optn \"%s\"",gbox->optn_list->label); struct GuiBox *gbox_over; struct GuiBoxOption *goptn_over; struct GuiBoxOption *goptn; long lnheight; long mouse_x,mouse_y; long pos_x,pos_y; LbTextSetWindow(0, 0, MyScreenWidth/pixel_size, MyScreenHeight/pixel_size); mouse_x = GetMouseX(); mouse_y = GetMouseY(); goptn_over = NULL; gbox_over = gui_get_box_point_over(mouse_x, mouse_y); if (gbox_over != NULL) { goptn_over = gui_get_box_option_point_over(gbox_over, mouse_x, mouse_y); } LbTextSetFont(font_sprites); lnheight = pixel_size * LbTextLineHeight() + 2; pos_y = gbox->pos_y + 8; pos_x = gbox->pos_x + 8; if (gbox != gui_get_highest_priority_box()) { lbDisplay.DrawFlags |= Lb_SPRITE_TRANSPAR4; LbDrawBox(gbox->pos_x/pixel_size, gbox->pos_y/pixel_size, gbox->width/pixel_size, gbox->height/pixel_size, colours[6][0][0]); if (lbDisplay.DrawFlags & Lb_SPRITE_OUTLINE) { LbDrawBox(gbox->pos_x/pixel_size, gbox->pos_y/pixel_size, gbox->width/pixel_size, gbox->height/pixel_size, colours[0][0][0]); } else { lbDisplay.DrawFlags ^= Lb_SPRITE_OUTLINE; LbDrawBox(gbox->pos_x/pixel_size, gbox->pos_y/pixel_size, gbox->width/pixel_size, gbox->height/pixel_size, colours[0][0][0]); lbDisplay.DrawFlags ^= Lb_SPRITE_OUTLINE; } lbDisplay.DrawFlags ^= Lb_SPRITE_TRANSPAR4; lbDisplay.DrawColour = colours[3][3][3]; goptn = gbox->optn_list; while (goptn->label[0] != '!') { if (goptn->active_cb != NULL) goptn->field_26 = (goptn->active_cb)(gbox, goptn, &goptn->field_D); else goptn->field_26 = 1; if (!goptn->field_26) lbDisplay.DrawColour = colours[0][0][0]; else lbDisplay.DrawColour = colours[3][3][3]; if (LbScreenIsLocked()) { LbTextDraw(pos_x/pixel_size, pos_y/pixel_size, goptn->label); } goptn++; pos_y += lnheight; } } else { lbDisplay.DrawFlags |= Lb_SPRITE_TRANSPAR4; LbDrawBox(gbox->pos_x/pixel_size, gbox->pos_y/pixel_size, gbox->width/pixel_size, gbox->height/pixel_size, colours[12][0][0]); if (lbDisplay.DrawFlags & Lb_SPRITE_OUTLINE) { LbDrawBox(gbox->pos_x/pixel_size, gbox->pos_y/pixel_size, gbox->width/pixel_size, gbox->height/pixel_size, colours[2][0][0]); } else { lbDisplay.DrawFlags ^= Lb_SPRITE_OUTLINE; LbDrawBox(gbox->pos_x/pixel_size, gbox->pos_y/pixel_size, gbox->width/pixel_size, gbox->height/pixel_size, colours[2][0][0]); lbDisplay.DrawFlags ^= Lb_SPRITE_OUTLINE; } lbDisplay.DrawFlags ^= Lb_SPRITE_TRANSPAR4; goptn = gbox->optn_list; while (goptn->label[0] != '!') { if (goptn->active_cb != NULL) goptn->field_26 = (goptn->active_cb)(gbox, goptn, &goptn->field_D); else goptn->field_26 = 1; if (!goptn->field_26) lbDisplay.DrawColour = colours[0][0][0]; else if ( ((gbox == gbox_over) && (goptn == goptn_over) && (gbox != dragging_box.gbox)) || ((gbox != NULL) && (goptn->active != 0)) ) lbDisplay.DrawColour = colours[15][15][15]; else lbDisplay.DrawColour = colours[9][9][9]; if (LbScreenIsLocked()) { LbTextDraw(pos_x/pixel_size, pos_y/pixel_size, goptn->label); } goptn++; pos_y += lnheight; } } }
void frontend_draw_define_key(struct GuiButton *gbtn) { long content, key_id; content = (long)gbtn->content; key_id = define_key_scroll_offset - content - 1; if (key_id >= GAME_KEYS_COUNT) { return; } unsigned char code; code = settings.kbkeys[key_id].code; long i; char chbuf[4]; const char * keyname; i = key_to_string[code]; if (i >= 0) { keyname = get_string(i); } else { chbuf[0] = -(char)i; chbuf[1] = 0; keyname = chbuf; } if (frontend_mouse_over_button == content) { LbTextSetFont(frontend_font[2]); } else { LbTextSetFont(frontend_font[1]); } lbDisplay.DrawFlags = Lb_TEXT_HALIGN_LEFT; int tx_units_per_px; // This text is a bit condensed - button size is smaller than text height tx_units_per_px = (gbtn->height*13/11) * 16 / LbTextLineHeight(); LbTextSetWindow(gbtn->scr_pos_x, gbtn->scr_pos_y, gbtn->width, gbtn->height); int height; height = LbTextLineHeight() * tx_units_per_px / 16; LbTextDrawResized(0, (gbtn->height - height) / 2, tx_units_per_px, get_string(definable_key_string[key_id])); unsigned char mods; mods = settings.kbkeys[key_id].mods; lbDisplay.DrawFlags = Lb_TEXT_HALIGN_RIGHT; char text[255]; text[0] = '\0'; if (mods & KMod_CONTROL) { strcat(text, get_string(GUIStr_KeyControl)); strcat(text, " "); } if (mods & KMod_ALT) { strcat(text, get_string(GUIStr_KeyAlt)); strcat(text, " "); } if (mods & KMod_SHIFT) { strcat(text, get_string(GUIStr_KeyShift)); strcat(text, " "); } const char *keytext; switch (code) { case KC_LSHIFT: case KC_RSHIFT: keytext = get_string(GUIStr_KeyShift); break; case KC_LCONTROL: case KC_RCONTROL: keytext = get_string(GUIStr_KeyControl); break; case KC_LALT: case KC_RALT: keytext = get_string(GUIStr_KeyAlt); break; default: keytext = keyname; break; } strcat(text, keytext); height = LbTextLineHeight() * tx_units_per_px / 16; LbTextDrawResized(0, (gbtn->height - height) / 2, tx_units_per_px, text); }
void frontend_draw_high_score_table(struct GuiButton *gbtn) { struct TbSprite *spr; struct TbSprite *swpspr; long pos_x,pos_y; long col1_width,col2_width,col3_width,col4_width; long i,k; // Detect scaling factor is quite complicated for this item int fs_units_per_px; { int orig_size; orig_size = 0; spr = &frontend_sprite[33]; for (i=0; i < 6; i++) { orig_size += spr->SWidth; spr++; } fs_units_per_px = (gbtn->width * 16 + orig_size/2) / orig_size; } // Draw the high scores area - top pos_x = gbtn->scr_pos_x; pos_y = gbtn->scr_pos_y; spr = &frontend_sprite[25]; swpspr = spr; for (i=6; i > 0; i--) { LbSpriteDrawResized(pos_x, pos_y, fs_units_per_px, swpspr); pos_x += swpspr->SWidth * fs_units_per_px / 16; swpspr++; } pos_y += spr->SHeight * fs_units_per_px / 16; // Draw the high scores area - filling k = 12; while (k > 0) { if (k < 3) i = 33; else i = 40; spr = &frontend_sprite[i]; pos_x = gbtn->scr_pos_x; swpspr = spr; for (i=6; i > 0; i--) { LbSpriteDrawResized(pos_x, pos_y, fs_units_per_px, swpspr); pos_x += swpspr->SWidth * fs_units_per_px / 16; swpspr++; } pos_y += spr->SHeight * fs_units_per_px / 16; if (k < 3) k--; else k -= 3; } // Draw the high scores area - bottom pos_x = gbtn->scr_pos_x; spr = &frontend_sprite[47]; swpspr = spr; for (i=6; i > 0; i--) { LbSpriteDrawResized(pos_x, pos_y, fs_units_per_px, swpspr); pos_x += swpspr->SWidth * fs_units_per_px / 16; swpspr++; } LbTextSetFont(frontend_font[1]); lbDisplay.DrawFlags = 0; spr = &frontend_sprite[33]; pos_x = gbtn->scr_pos_x + spr->SWidth * fs_units_per_px / 16; spr = &frontend_sprite[25]; pos_y = gbtn->scr_pos_y + (spr->SHeight + 3) * fs_units_per_px / 16; int tx_units_per_px; // The GUI item height should be 11 lines of text tx_units_per_px = gbtn->height * 16 / (11*(LbTextLineHeight())); col1_width = LbTextStringWidth("99") * tx_units_per_px / 16; col2_width = LbTextStringWidth(" 99999") * tx_units_per_px / 16; col3_width = LbTextStringWidth(" 999") * tx_units_per_px / 16; col4_width = LbTextCharWidth('-') * tx_units_per_px / 16; for (k=0; k < VISIBLE_HIGH_SCORES_COUNT-1; k++) { draw_high_score_entry(k, pos_x, pos_y, col1_width, col2_width, col3_width, col4_width, tx_units_per_px); pos_y += LbTextLineHeight() * tx_units_per_px / 16; } if (high_score_entry_input_active > k) draw_high_score_entry(high_score_entry_input_active, pos_x, pos_y, col1_width, col2_width, col3_width, col4_width, tx_units_per_px); else draw_high_score_entry(k, pos_x, pos_y, col1_width, col2_width, col3_width, col4_width, tx_units_per_px); }