Esempio n. 1
0
File: gui.c Progetto: pasoev/innfin
static void render_bar(struct engine *engine, int x, int y, int w,
                       const char *name, double value, const double max_value,
                       TCOD_color_t bar_col, TCOD_color_t back_col)
{
    TCOD_console_set_default_background(engine->gui->con, back_col);
    TCOD_console_rect(engine->gui->con, x, y, w, 1, false,
                      TCOD_BKGND_SET);

    int bar_w = (int) (value / max_value * w);
    if (bar_w > 0) {
        /* Draw the bar */
        TCOD_console_set_default_background(engine->gui->con, bar_col);
        TCOD_console_rect(engine->gui->con, x, y, bar_w, 1, false,
                          TCOD_BKGND_SET);
    }

    /* Print text on top of a bar */
    TCOD_color_t hp_color = TCOD_black;
    TCOD_console_set_default_foreground(engine->gui->con, hp_color);
    TCOD_console_print_ex(engine->gui->con, x + w / 2, y,
                          TCOD_BKGND_NONE, TCOD_CENTER, "%s : %.0f/%.0f",
                          name, value, max_value);
}
Esempio n. 2
0
void TCOD_console_print_double_frame(TCOD_console_t con,int x,int y,int w,int h, bool empty, TCOD_bkgnd_flag_t flag, const char *fmt, ...) {
	TCOD_console_data_t *dat = con ? (TCOD_console_data_t *)con : TCOD_ctx.root;
	TCOD_console_put_char(con,x,y,TCOD_CHAR_DNW,flag);
	TCOD_console_put_char(con,x+w-1,y,TCOD_CHAR_DNE,flag);
	TCOD_console_put_char(con,x,y+h-1,TCOD_CHAR_DSW,flag);
	TCOD_console_put_char(con,x+w-1,y+h-1,TCOD_CHAR_DSE,flag);
	TCOD_console_double_hline(con,x+1,y,w-2, flag);
	TCOD_console_double_hline(con,x+1,y+h-1,w-2, flag);
	TCOD_console_double_vline(con,x,y+1,h-2, flag);
	TCOD_console_double_vline(con,x+w-1,y+1,h-2, flag);
	if ( h > 2 ) {
		TCOD_console_vline(con,x,y+1,h-2,flag);
		TCOD_console_vline(con,x+w-1,y+1,h-2,flag);
		if ( empty ) {
			TCOD_console_rect(con,x+1,y+1,w-2,h-2,true,flag);
		}
	}
	if (fmt) {
		va_list ap;
		int xs;
		TCOD_color_t tmp;
		char *title;
		va_start(ap,fmt);
		title = TCOD_console_vsprint(fmt,ap);
		va_end(ap);
		title[w-3]=0; /* truncate if needed */
		xs = x + (w-strlen(title)-2)/2;
		tmp=dat->back; /* swap colors */
		dat->back=dat->fore;
		dat->fore=tmp;
		TCOD_console_print_ex(con,xs,y,TCOD_BKGND_SET,TCOD_LEFT," %s ",title);
		tmp=dat->back; /* swap colors */
		dat->back=dat->fore;
		dat->fore=tmp;
	}
}
Esempio n. 3
0
void TCODConsole::rect(int x,int y, int rw, int rh, bool clear, TCOD_bkgnd_flag_t flag) {
	TCOD_console_rect(data,x,y,rw,rh,clear,flag);
}