/* Look (builtin) for 'arg' in the context of 'v' */ void view_look (View *v, char *arg) { Bool found = false; ulong p; Range r; assert(ISBODY(v)); if( ! text_length(v->t)) return ; p = (v->sel.p0 + 1) % text_length(v->t); r = range(p, p); if(arg) { found = text_findliteralutf(v->t, &r, arg); } else if (RLEN(v->sel) ){ found = text_look(v->t, &r, v->sel); } else { found = false; } if(found){ view_show(v,r); view_select(v, r); view_setlastselection(v); } }
menu::menu(const char* ptab[],int pnb) { float pasy,hint,xint,lmax,hmax; int taillemax,ind; nb=pnb; taillemax = text_length(font,ptab[0]); for(int i=0;i<nb;i++) { if(text_length(font,ptab[i])>taillemax) { taillemax = text_length(font,ptab[i]); ind = i; } } lmax = taillemax + 20; hmax = text_height(font) + 10; hint = taillemax + 10; xint = 20 + hint/2; pasy = (SCREEN_H)/(nb+1); tab = new bouton*[nb]; for(int i=0;i<nb;i++) { tab[i] = new bouton(xint,(i+1)*pasy,ptab[i]); tab[i]->rectangle::init(lmax, hmax); } }
void string_shorten(std::string& s, const FONT* ft, const int len) { if (text_length(ft, s.c_str()) < len) return; const std::string append = (len >= 100 ? "..." : "."); while (! s.empty() && text_length(ft, (s + append).c_str()) > len) Help::remove_last_utf8_char(s); s += append; }
/** * Sets correct value ranges in GUI controls * after the user changes information related to skins */ static void fixup_unit_info() { if (sol_dialog[D_RACE].d1 == 0) { armour_names = armour_names_human; appearance_names = appearance_names_human; } else if (sol_dialog[D_RACE].d1 == (SKIN_NUMBER - 4)) { //LAWYER: This really should be a little more visible - adding more units needs this number changed armour_names = armour_names_chameleon; init_chameleon_appearances(); } else { armour_names = armour_names_alien; appearance_names = appearance_names_alien; } if (sol_dialog[D_ARMOUR].d1 >= get_list_size(armour_names)) sol_dialog[D_ARMOUR].d1 = 0; if (sol_dialog[D_APPEARANCE].d1 >= get_list_size(appearance_names)) sol_dialog[D_APPEARANCE].d1 = 0; DIALOG *d; d = &sol_dialog[D_RACE]; d->w = text_length(font, race_names[d->d1]) + 6; d->dp = (void *)race_names[d->d1]; d = &sol_dialog[D_APPEARANCE]; d->w = text_length(font, appearance_names[d->d1]) + 6; d->dp = (void *)appearance_names[d->d1]; d = &sol_dialog[D_ARMOUR]; d->w = text_length(font, armour_names[d->d1]) + 6; d->dp = (void *)armour_names[d->d1]; }
int AWgtOption::findWidth() { int w = optionPadding * 2; if (optionLeftBmp) w += optionLeftBmp->w; else w += optionDefaultHeight; if (optionRightBmp) w += optionLeftBmp->w; else w += optionDefaultHeight; int max = 0; for (unsigned int i = 0; i < options->size(); i++) { if (text_length(aWgtFont, (*options)[i]) > max) { max = text_length(aWgtFont, (*options)[i]); } } w += max; return w; }
int d_abitmap_list_proc (int msg, DIALOG *d, int c) { if (msg == MSG_DRAW) { BITMAP *bmp = gui_get_screen(); int height, size, i, len, bar, x, y; char *sel = d->dp2; char s[1024]; int c = 0; if (d->flags & D_GOTFOCUS) c = 1; if (d->flags & D_DISABLED) c = 2; (*(char *(*)(int, int *)) d->dp) (-1, &size); height = (d->h - 4) / text_height (font); bar = (size > height); abitmap_draw_area (d, B_LIST, 0, 0, bar ? d->w - 12 : d->w, d->h, 0, 0); if (bar) abitmap_draw_scroller (d, d->d2, size, height); /* draw the contents */ for (i = 0; i < height; i++) { if (d->d2 + i < size) { int fg = theme->bitmaps[B_LIST][c].color; x = d->x + 2; y = d->y + 2 + i * text_height (font); if (d->d2 + i == d->d1 || ((sel) && (sel[d->d2 + i]))) { abitmap_draw_area (d, B_LIST_ITEM, 0, y - d->y, bar ? d->w - 12 : d->w, text_height (font), 0, 0); fg = theme->bitmaps[B_LIST_ITEM][c].color; } ustrzcpy (s, sizeof (s), (*(char *(*)(int, int *)) d->dp) (i + d->d2, NULL)); x += 8; len = ustrlen (s); while (text_length (font, s) >= MAX (d->w - 1 - (bar ? 22 : 11), 1)) { len--; usetat (s, len, 0); } textout_ex (bmp, font, s, x, y, fg, -1); x += text_length (font, s); } } return D_O_K; } return d_list_proc (msg, d, c); }
void Editor::draw() { // Background rectfill(buffer, 0, 0, SCREEN_W, SCREEN_H, makecol(255,255,255)); if( saving){ //Create gui textprintf_centre_ex(buffer,font,640,310, makecol(0,0,0),-1,"Save Map Name"); //Input rectangle rectfill(buffer, 400, 408, 892, 452, makecol(0,0,0)); rectfill(buffer, 402, 410, 890, 450, makecol(255,255,255)); // Output the string to the screen textout_ex(buffer, font, edittext.c_str(), 410, 410, makecol(0,0,0), -1); // Draw the caret vline(buffer, text_length(font, edittext.c_str()) + 410 - text_length(font, ".txt") , 412, 448, makecol(0,0,0)); } else if( opening){ //Create gui textprintf_centre_ex(buffer,font,640,310, makecol(0,0,0),-1,"Open Map Name"); //Input rectangle rectfill(buffer, 400, 408, 892, 452, makecol(0,0,0)); rectfill(buffer, 402, 410, 890, 450, makecol(255,255,255)); // Output the string to the screen textout_ex(buffer, font, edittext.c_str(), 410, 410, makecol(0,0,0), -1); // Draw the caret vline(buffer, text_length(font, edittext.c_str()) + 410 - text_length(font, ".txt") , 412, 448, makecol(0,0,0)); } else{ // Draw tiles tile_map -> draw_map( buffer); exampleTile -> draw_tile( buffer, 0, 0, 0); // Map info textprintf_ex(buffer,font,0,80,makecol(255,255,255),makecol(0,0,0),"height-%i width-%i", tile_map -> height, tile_map -> width); if(layer == 1){ textprintf_ex(buffer,font,0,130,makecol(255,255,255),makecol(0,0,0),"Editing Mode: Foreground"); } else if(layer == 0){ textprintf_ex(buffer,font,0,130,makecol(255,255,255),makecol(0,0,0),"Editing Mode: Background"); } // Cursor circlefill(buffer, mouse_x , mouse_y , 10, makecol(0,0,0)); circlefill(buffer, mouse_x , mouse_y, 8, makecol(255,255,255)); } // Draw buffer stretch_sprite( screen, buffer, 0, 0, SCREEN_W, SCREEN_H); }
int Tabs::calcTabWidth(Tab* tab) { int border = 4*jguiscale(); #ifdef CLOSE_BUTTON_IN_EACH_TAB SkinTheme* theme = static_cast<SkinTheme*>(this->theme); int close_icon_w = theme->get_part(PART_WINDOW_CLOSE_BUTTON_NORMAL)->w; return (border + text_length(getFont(), tab->text.c_str()) + border + close_icon_w + border); #else return (border + text_length(getFont(), tab->text.c_str()) + border); #endif }
void gtext_render(void) { char tempstr[64]; /* temp variable */ int n; /* loop counter */ /* clear the buffer */ clear(damp_gfx_buffer); /* display volume */ textout(damp_gfx_buffer,font,"Volume:",0,30,makecol(255,255,0)); sprintf(tempstr,"%d",damp_volume); textout(damp_gfx_buffer,font,tempstr,text_length(font,"Volume:"),30,makecol(128,128,128)); /* display track time */ textout(damp_gfx_buffer,font,"Time:",160,30,makecol(255,255,0)); sprintf(tempstr,"%s",damp_display_time_remaining ? timeremainstr : timestr); textout(damp_gfx_buffer,font,tempstr,160+text_length(font,"Time:"),30,makecol(128,128,128)); /* display status */ textout(damp_gfx_buffer,font,"================ STATUS ================", 0, 50, makecol(255,128,64)); textout(damp_gfx_buffer,font,"Surround",30,60,audio_driver->surround ? makecol(255,255,0) : makecol(64,64,64)); textout(damp_gfx_buffer,font,"Continuous",30+text_length(font,"Surround "),60,damp_playlist_continuous ? makecol(255,255,0) : makecol(64,64,64)); textout(damp_gfx_buffer,font,"Random",30+text_length(font,"Surround Continuous "),60,damp_playlist_random ? makecol(255,255,0) : makecol(64,64,64)); /* display scrolling track name */ textout(damp_gfx_buffer,font,"============== NOW PLAYING =============", 0, 80, makecol(255,128,64)); textout(damp_gfx_buffer,font,&damp_gfx_scroll_name[damp_gfx_scroll_name_pos],0,90,makecol(255,255,255)); if(track_sel_pos > 0) textout_centre(damp_gfx_buffer,font,track_sel,160,100,makecol(255,255,255)); /* display vu */ if(damp_want_scope) { textout(damp_gfx_buffer,font,"VU-meter:",0,110,makecol(255,255,0)); for(n=0;n<32;n++) textout(damp_gfx_buffer,font,n==gtext_vu_max/2 ? "I" : (n<damp_vu/2 ? "=" : "-"),n*10,120,(n < damp_vu/2) ? (n<16 ? makecol(0,255,0) : (n<24 ? makecol(255,255,0) : makecol(255,0,0))) : makecol(128,128,128)); } /* display "advert" :-) */ textout_centre(damp_gfx_buffer,font,"DAMP",160,140,makecol(255,0,0)); textout_centre(damp_gfx_buffer,font,"Copyright 1999/2000 Hedgehog Software",160,150,makecol(255,0,0)); textout_centre(damp_gfx_buffer,font,"http://www.damp-mp3.co.uk/",160,160,makecol(255,0,0)); /* display it all */ if(!damp_using_gui) blit(damp_gfx_buffer,screen,0,0,0,0,DAMP_GFX_SCREEN_WIDTH,DAMP_GFX_SCREEN_HEIGHT); }
void draw_button(BITMAP *bmp, int x, int y, int w, int h, int col, const char *txt, bool selected, bool disabled) { int col1 = makecol( minf(255,getr(col)*1.3f), minf(255,getg(col)*1.3f), minf(255,getb(col)*1.3f) ); int col2 = makecol( getr(col)*0.7f, getg(col)*0.7f, getb(col)*0.7f ); int col3 = makecol( minf(255,getr(col)*1.7f), minf(255,getg(col)*1.7f), minf(255,getb(col)*1.7f) ); if(disabled) { col1 = makecol(130,130,130); col2 = makecol(50,50,50); col3 = makecol(170,170,170); col = makecol(100,100,100); } else if(selected) { rect(bmp, x-2,y-2, x+w+3,y+h+3, makecol(210,210,0)); rect(bmp, x-1,y-1, x+w+2,y+h+2, makecol(255,255,0)); col3 = makecol(255,255,255); } rectfill(bmp, x,y, x+w,y+h, col); line(bmp, x,y, x+w,y, col1); line(bmp, x+w,y, x+w,y+h, col1); line(bmp, x,y+1, x+w,y+1, col1); line(bmp, x+w+1,y, x+w+1,y+h, col1); line(bmp, x,y+h, x+w,y+h, col2); line(bmp, x,y, x,y+h, col2); line(bmp, x,y+h+1, x+w,y+h+1, col2); line(bmp, x+1,y, x+1,y+h, col2); textout_ex(bmp, font2, txt, x + (w/2) - (text_length(font2,txt)/2), y + (h/2) - (text_height(font2)/2), col3, -1); }
// map (x) coordinate to character number int TextInfo::getcharpos(char *scantxt, int x, int max) { STACKTRACE; int i; i = 0; double len, charlen, lastcharlen; len = 0; charlen = 0; while (scantxt[i] != 0 && i < max) { char txt[2]; txt[0] = scantxt[i]; txt[1] = 0; lastcharlen = charlen; charlen = text_length(usefont, txt); // so that sensitivity is to the center of the character len += 0.5 * (charlen + lastcharlen); if (len > x) break; ++i; } return i; }
// go from line-coordinate to bitmap coordinate void TextInfo::getxy(int charpos, int *x, int *y) { STACKTRACE; int iline; iline = 0; while (iline+1 < Nlines && linestart[iline+1] <= charpos) ++iline; *y = iline * Htxt; // on this line, find the x-position... int n, len; n = linestart[iline]; len = 0; while (n < charpos) { char txt[2]; txt[0] = textinfo[n]; txt[1] = 0; len += text_length(usefont, txt); ++n; } *x = len; }
Imagen::Imagen(Fuente *fuente, string texto, int r, int g, int b) { if ( !fuente ) { bitmap = NULL ; throw Error::ExcepcionParametro("Graficos::Imagen::Imagen(Fuente *, string)", 1); } // Creamos el bitmap con el tamaño apropiado bitmap = create_bitmap( text_length(fuente->GetFont(), texto.c_str()), text_height(fuente->GetFont()) ); if (!bitmap) { throw Error::ExcepcionLocalizada("Graficos::Imagen::Imagen(Fuente *, string)", "No se pudo crear el bitmap"); } // Pintamos el texto en el bitmap creado, con el color que trae de "fabrica" // y con el color de fondo trasparente textout_ex(bitmap, fuente->GetFont(), texto.c_str(), 0, 0, makecol(r,g,b), makecol(255,0,255)); // Por defecto una imagen no se pinta con mascara trasparente, pero una // imagen generada por una fuente si que lo hace por defecto. masked = true ; textura = allegro_gl_make_masked_texture(bitmap); w = bitmap->w ; h = bitmap->h ; destroy_bitmap(bitmap); bitmap = NULL ; }
AWgtButton::AWgtButton(int x, int y, int width, int height, std::vector<int>* hotkeys, char* text, int top_color, int bottom_color, int border_color, int text_color, int shadowColor, int shadowType) { this->x = x; this->y = y; if (width < 0) this->width = text_length(aWgtFont, text) + (buttonPadding*2) + 2; else this->width = width; if (height < 0) this->height = text_height(aWgtFont) + (buttonPadding*2) + 2; else this->height = height; this->hotkeys = hotkeys; this->text = text; this->top_color = top_color; this->bottom_color = bottom_color; this->border_color = border_color; this->text_color = text_color; this->shadowColor = shadowColor; this->shadowType = shadowType; pressed = false; depressed = false; clicked = false; }
int cin_num(char *lab, int x, int y, int col) { clear_keybuf(); char *st_edit = new char[101]; st_edit[100] = char(NULL); char null_char = char(NULL); st_edit[0] = null_char; int st_pos = 0; while(!key[KEY_ENTER]) { rectfill(screen,x,y,screen->w-1,y+10,BLACK); textprintf(screen,font,x,y,col,lab); textprintf(screen,font,x+text_length(font,lab),y,col,st_edit); st_edit[st_pos] = readkey() % 256; st_edit[st_pos+1] = null_char; if(!key[KEY_BACKSPACE]) st_pos++; else if(st_pos) {st_pos--; st_edit[st_pos] = null_char;} int char_num = int(st_edit[st_pos-1]); if((char_num < 48 || char_num > 57) && st_pos){st_pos--;st_edit[st_pos] = null_char;} } int ret_num = 0; for(int snum = 0; snum < st_pos; snum++) ret_num += int((int(st_edit[snum])-48) * pow(10,st_pos-snum-1)); return ret_num; }
void GuiLabel::addLabel(short x, short y, int color, string label) { if (firstLabel==NULL) { firstLabel = new LABEL_MASK; lastLabel = firstLabel; lastLabel->next = NULL; lastLabel->previous = NULL; } else { lastLabel->next = new LABEL_MASK; lastLabel->next->previous = lastLabel; lastLabel = lastLabel->next; lastLabel->next = NULL; } lastLabel->x = x; lastLabel->y = y; lastLabel->w = text_length(font, label.c_str())+10; lastLabel->h = text_height(font)+10; lastLabel->color = color; lastLabel->label = label; lastLabel->displayed = true; lastLabel->destroyed=false; lastLabel->ID = auto_increment_id; auto_increment_id++; labelAttributes = lastLabel; }
void AWgtCheckbox::draw() { int tx; int ty; if (checkCheckedBmp) { if (checked) draw_sprite(tguiBitmap, checkCheckedBmp, x, y); else draw_sprite(tguiBitmap, checkUncheckedBmp, x, y); tx = x + checkCheckedBmp->w + checkPadding; ty = y + ((checkCheckedBmp->h - text_height(aWgtFont)) / 2); } else { int w = text_height(aWgtFont); rect(tguiBitmap, x, y, x+w-1, y+w-1, shadowColor); rectfill(tguiBitmap, x+1, y+1, x+w-2, y+w-2, textColor); if (checked) { line(tguiBitmap, x+1, y+1, x+w-2, y+w-2, shadowColor); line(tguiBitmap, x+1, y+w-2, x+w-2, y+1, shadowColor); } tx = x + w + checkPadding; ty = y; } aWgtTextout(tguiBitmap, aWgtFont, text, tx, ty, textColor, shadowColor, shadowType); if (focus) { drawing_mode(DRAW_MODE_MASKED_PATTERN, linePatternBmp, 0, 0); rect(tguiBitmap, tx-2, ty-2, tx+text_length(aWgtFont, text)+2, ty+text_height(aWgtFont)+2, aWgtFocusColor); drawing_mode(DRAW_MODE_SOLID, 0, 0, 0); } }
void ce_game::drawTitle(const char *text, ce_cord center){ //Draw a title dependant on parameters given BITMAP *bmp = create_bitmap(text_length(font, text),text_height(font)); clear_to_color(bmp,makecol(0,0,0)); textout_ex(bmp, font, text, 0, 0, makecol(240,0,240), -1); stretch_blit(bmp,buffer, 0,0,bmp->w, bmp->h, center.x - ((bmp->w*5)/2), center.y - ((bmp->h*5)/2),bmp->w * 5, bmp->h * 5); destroy_bitmap(bmp); }
/** * Show TUs needed to move an item to a place like hand, belt, backpack etc. */ void Place::draw_deselect_time(BITMAP *dest, int PLACE_NUM, int time) { int color = COLOR_WHITE; if (time) { int ISLOCAL = platoon_local->belong(sel_man); if (sel_man->time_reserve(time, ISLOCAL, 0) != OK) color = COLOR_RED; printsmall_x(dest, gx + 1 + text_length(g_small_font, place_name[PLACE_NUM]), gy - 6, color, time); } }
/*! \brief Show the current console * * Display the current state of the console on the double * buffer. This includes a horizontal line. The console takes * up 320x120 pixels. * \author PH * \param xofs x-offset display position * \param yofs y-offset display position */ void display_console(int xofs, int yofs) { int i, y; if (g_console.on != 1) return; rectfill(double_buffer, xofs, yofs + 120, xofs + 320, yofs + 240, makecol(0,0,0)); hline(double_buffer, xofs, yofs + 120, xofs + 320, makecol(255,255,255)); y = yofs + 240 - 2 * text_height(font); i = 24; while (y > yofs + 120) { if (g_console.lines[i]) { textout_ex(double_buffer, font, g_console.lines[i], xofs, y, makecol(255,255,255), makecol(0,0,0)); } y -= text_height(font); --i; } textout_ex(double_buffer, font, g_console.inputline, xofs, yofs + 240 - text_height(font), makecol(255,255,255), makecol(0,0,0)); rectfill(double_buffer, xofs + text_length(font, g_console.inputline), yofs + 238, xofs + text_length(font, g_console.inputline) + text_length(font, "_"), yofs + 240, makecol(192,192,192)); }
void AWgtButton::draw() { int color; if (focus) { drawing_mode(DRAW_MODE_MASKED_PATTERN, linePatternBmp, 0, 0); color = aWgtFocusColor; } else color = border_color; line(tguiBitmap, x+2, y, x+width-3, y, color); line(tguiBitmap, x, y+2, x, y+height-3, color); line(tguiBitmap, x+width-1, y+2, x+width-1, y+height-3, color); line(tguiBitmap, x+2, y+height-1, x+width-3, y+height-1, color); if (focus) drawing_mode(DRAW_MODE_SOLID, 0, 0, 0); int faceHeight = height - 2; int i; for (i = 0; i < faceHeight; i++) { float ratio = (float)i / (float)faceHeight; int color; if (depressed) color = aWgtInterpolateColor(ratio, bottom_color, top_color); else color = aWgtInterpolateColor(ratio, top_color, bottom_color); line(tguiBitmap, x+1, y+1+i, x+width-2, y+1+i, color); } putpixel(tguiBitmap, x+1, y+1, border_color); putpixel(tguiBitmap, x+width-2, y+1, border_color); putpixel(tguiBitmap, x+width-2, y+height-2, border_color); putpixel(tguiBitmap, x+1, y+height-2, border_color); int tx = x + (width/2) - (text_length(aWgtFont, text)/2); int ty = y + (height/2) - (text_height(aWgtFont)/2); if (depressed) { tx += 2; ty += 2; color = aWgtDarken(text_color); } else color = text_color; aWgtTextout(tguiBitmap, aWgtFont, text, tx, ty, color, shadowColor, shadowType); }
void render_info(BITMAP *bmp) { char buf[256]; scare_mouse(); rectfill(bmp, 0, bmp->h - 16, bmp->w/2, bmp->h, bgc); rectfill(bmp, bmp->w/3, 0, (int)bmp->w*.66, 10, bgc); if (selected_node) { snprintf(buf, sizeof(buf), "%s: %s (ID: %d coord: %d,%d)", (selected_node->area?selected_node->area:"(unknown area)"), (selected_node->title?selected_node->title:"(unknown title)"), selected_node->id, selected_node->x, selected_node->y); textprintf_centre_ex(bmp, font, bmp->w/2, 2, 0, -1, "%s", buf); hline(bmp, bmp->w/2 - text_length(font, buf)/2, 10, bmp->w/2 + text_length(font, buf)/2, 0); highlight_node(selected_node, highlight_color); } textprintf_ex(bmp, font, 2, (bmp->h - 8) - 2 - text_height(font), 0, -1, "Center: %d,%d", (int)(bmp->w/2.0+xoffset), (int)(bmp->h/2.0+yoffset)); textprintf_ex(bmp, font, 2, bmp->h - 8, 0, -1, "Mouse: %d,%d", mouse_x+xoffset, mouse_y+yoffset); if (last_file) { snprintf(buf, sizeof(buf), "Most recent file: \"%s\" (%d nodes total)", last_file, vector_len((vector_t *)nodelist)); rectfill(bmp, text_length(font, buf), bmp->h - text_height(font), bmp->w, bmp->h, bgc); textprintf_right_ex(bmp, font, bmp->w, bmp->h-10, 0, -1, "%s", buf); } unscare_mouse(); }
void Imagen::GenerarTexto(string texto, int color) { if ( bitmap ) { destroy_bitmap(bitmap); bitmap = NULL ; } bitmap = create_bitmap( text_length(font, texto.c_str()), text_height(font) ); textout_ex(bitmap, font, texto.c_str(), 0, 0, color, makecol(255,0,255)); mascara = true ; }
/***************************************************************************** Function: osd_gfx_set_message Description: compute the message that will be displayed to create a sprite to blit on screen Parameters: char* mess, the message to display Return: nothing but set OSD_MESSAGE_SPR *****************************************************************************/ void osd_gfx_set_message(char* mess) { if (OSD_MESSAGE_SPR) destroy_bitmap(OSD_MESSAGE_SPR); OSD_MESSAGE_SPR=create_bitmap(text_length(font,mess)+1,text_height(font)+1); clear(OSD_MESSAGE_SPR); textout(OSD_MESSAGE_SPR,font,mess,1,1,3); textout(OSD_MESSAGE_SPR,font,mess,0,0,255); return; }
AWgtText::AWgtText(int x, int y, char* text, int textColor, int shadowColor, int shadowType) { this->x = x; this->y = y; this->width = text_length(aWgtFont, text); this->height = text_height(aWgtFont); this->text = text; this->textColor = textColor; this->shadowColor = shadowColor; this->shadowType = shadowType; this->hotkeys = 0; }
Menu::Menu() : m_up(KEY_UP) , m_down(KEY_DOWN) , m_enter(KEY_ENTER) , m_esc(KEY_ESC) { m_start_time = GAME_T; m_selected = 0; m_options = 4; m_logo = create_bitmap(text_length(gamefont, gametitle), text_height(gamefont)); clear_to_color(m_logo, bitmap_mask_color(m_logo)); draw_text(m_logo, 0, 0, makecol(200, 180, 0), gametitle); }
static void init_messages(DIALOG *d) { unsigned int i; __mlog.c = (d->w - d->x) / text_length(font, WIDEST_CHAR); __mlog.l = d->h / (text_height(font) + 2); __mlog.lines = NULL; /* This buffer is for new messages... */ __mlog.tmp = calloc(__mlog.l + 1, sizeof(char *)); for (i = 0; i < __mlog.l; i++) __mlog.tmp[i] = calloc(MAX_LINE_CHARS + 1, sizeof(char)); }
AWgtCheckbox::AWgtCheckbox(int x, int y, std::vector<int>* hotkeys, char* text, int textColor, int shadowColor, int shadowType, bool checked) { this->x = x; this->y = y; if (checkCheckedBmp) { this->width = text_length(aWgtFont, text) + checkPadding + checkCheckedBmp->w; this->height = checkCheckedBmp->h; } else { this->width = text_length(aWgtFont, text) + checkPadding + text_height(aWgtFont); this->height = text_height(aWgtFont); } this->hotkeys = hotkeys; this->text = text; this->textColor = textColor; this->shadowColor = shadowColor; this->shadowType = shadowType; this->checked = checked; }
// shows a speak bulb void draw_speak_bulb(BITMAP *bmp, DATAFILE *d, int src_x, int src_y, int up, int left, int lines, char **rows, int arrow) { int i; int max_w = 0; int x1, y1, x2, y2; // bulb coords int xa, ya; // bulb_arrow position // get max text length for(i = 0; i < lines; i ++) { int len = text_length(d[THE_FONT].dat, rows[i]); if (max_w < len) max_w = len; } // calc bulb position x1 = MAX(src_x - max_w/2 - 8, 4); x2 = x1 + max_w + 8; if (x2 > 156) { x2 = 156; x1 = x2 - max_w - 16; } y2 = src_y - 10; y1 = src_y - 10 - lines * 9 - 8; xa = src_x - 4; ya = (up ? y1 - 10: src_y - 10); // draw the bulb rectfill(bmp, x1, y1 + 4, x2, y2 - 4, 4); rectfill(bmp, x1 + 4, y1, x2 - 4, y2, 4); line(bmp, x1, y1 + 4, x1, y2 - 4, 1); line(bmp, x1 + 4, y1, x2 - 4, y1, 1); line(bmp, x2, y1 + 4, x2, y2 - 4, 1); line(bmp, x1 + 4, y2, x2 - 4, y2, 1); line(bmp, x2+1, y1 + 4, x2+1, y2 - 4, 1); line(bmp, x1 + 4, y2+1, x2 - 4, y2+1, 1); draw_sprite(bmp, d[BULB_TL].dat, x1, y1); draw_sprite(bmp, d[BULB_BL].dat, x1, y2 - 5); draw_sprite(bmp, d[BULB_TR].dat, x2 - 5, y1); draw_sprite(bmp, d[BULB_BR].dat, x2 - 5, y2 - 5); if (arrow) draw_sprite(bmp, d[(left ? (up ? BULBA_TL : BULBA_BL) : (up ? BULBA_TR : BULBA_BR))].dat, xa, ya); // draw text for(i = 0; i < lines; i ++) { textout_ex(bmp, d[THE_FONT].dat, rows[i], x1 + 4, y1 + 5 + i * 9, 1, -1); } }
char *cin_str(char *lab, int x, int y, int col) { clear_keybuf(); char *st_edit = new char[101]; st_edit[100] = char(NULL); char null_char = char(NULL); st_edit[0] = null_char; int st_pos = 0; while(!key[KEY_ENTER]) { rectfill(screen,x,y,screen->w-1,y+10,BLACK); textprintf(screen,font,x,y,col,lab); textprintf(screen,font,x+text_length(font,lab),y,col,st_edit); st_edit[st_pos] = readkey() % 256; st_edit[st_pos+1] = null_char; if(!key[KEY_BACKSPACE]) st_pos++; else if(st_pos) {st_pos--; st_edit[st_pos] = null_char;} } st_pos--; st_edit[st_pos] = null_char; return st_edit; }