示例#1
0
void consoleInputDraw() {
	for (int x = 76; x < 99; x++)
		TCOD_console_put_char(NULL, x, 73, ' ', TCOD_BKGND_NONE);

	TCOD_console_print_left_rect(NULL, 76, 73, 23, 1, TCOD_BKGND_NONE, g_cConsoleInput);
	return;
}
示例#2
0
void consoleDraw() {
	TCOD_console_put_char(NULL, 75, 44, 204, TCOD_BKGND_NONE);
	for (int x = 76; x < 99; x++)
		TCOD_console_put_char(NULL, x, 44, 205, TCOD_BKGND_NONE);
	TCOD_console_put_char(NULL, 99, 44, 185, TCOD_BKGND_NONE);
	TCOD_console_print_left(NULL, 78, 44, TCOD_BKGND_NONE, "Console");

	for (int x = 76; x < 99; x++)
		for (int y = 45; y < 73; y++)
			TCOD_console_put_char(NULL, x, y, ' ', TCOD_BKGND_NONE);

	int iCount = 0;
	int iHeight = 0;

	for (int i = 0; i < 32; i++) {
		if (g_cConsole[i] != NULL) {
			iCount += iHeight = TCOD_console_height_left_rect(NULL, 76, 45, 23, 29, g_cConsole[i]);
			if (iCount < 29)
				TCOD_console_print_left_rect(NULL, 76, 73-iCount, 23, iHeight, TCOD_BKGND_NONE, g_cConsole[i]);
		}
	}
	return;
}
示例#3
0
/* renders the textfield */
void TCOD_text_render (TCOD_console_t con, TCOD_text_t txt) {
    text_t * data = (text_t*)txt;
    uint32 time = TCOD_sys_elapsed_milli();
	bool cursor_on = (int)( time % data->interval ) > data->halfinterval;
	char back=0;
	int curx,cury,cursorx,cursory, curpos;
	char *ptr;
    TCOD_console_set_background_color(data->con, data->back);
    TCOD_console_set_foreground_color(data->con, data->fore);
    TCOD_console_clear(data->con);

	/* compute cursor position */
	get_cursor_coords(data,&cursorx,&cursory);

	if ( cursor_on && data->ascii_cursor) {
		/* save the character under cursor position */
		back = data->text[data->cursor_pos];
		data->text[data->cursor_pos] = data->ascii_cursor;
	}
	/* render prompt */
    if (data->prompt) TCOD_console_print_left_rect(data->con,0,0,data->w,data->h,TCOD_BKGND_SET,"%s",data->prompt);
	/* render text */
	curx=data->textx;
	cury=data->texty;
	ptr=data->text;
	curpos=0;
	while (*ptr) {
		if ( *ptr == '\n') {
			if ( (curx == 0 || curpos == 0 ) && curpos >= data->sel_start && curpos < data->sel_end ) {
				/* inverted colors for selected empty lines */
				TCOD_console_set_back(data->con, curx, cury, data->fore, TCOD_BKGND_SET);
				TCOD_console_set_fore(data->con, curx, cury, data->back);
			}
			curx=0;
			cury++;
		} else {
			if ( curpos >= data->sel_start && curpos < data->sel_end ) {
				/* inverted colors for selection */
				TCOD_console_set_back(data->con, curx, cury, data->fore, TCOD_BKGND_SET);
				TCOD_console_set_fore(data->con, curx, cury, data->back);
			}
			TCOD_console_set_char(data->con,curx,cury,*ptr);
			curx++;
			if ( curx == data->w ) {
				curx=0;
				cury++;
			}
		}
		ptr++;
		curpos++;
	}
	if ( cursor_on ) {
		if ( data->ascii_cursor) {
			/* restore the character under cursor */
			data->text[data->cursor_pos] = back;
		} else {
			/* invert colors at cursor position */
			TCOD_console_set_back(data->con,cursorx,cursory,data->fore,TCOD_BKGND_SET);
			TCOD_console_set_fore(data->con,cursorx,cursory,data->back);
		}
	} else if (! cursor_on && ! data->ascii_cursor && data->multiline ) {
		/* normal colors for cursor ( might be inside selection ) */
		TCOD_console_set_back(data->con,cursorx,cursory,data->back,TCOD_BKGND_SET);
		TCOD_console_set_fore(data->con,cursorx,cursory,data->fore);
	}
    TCOD_console_blit(data->con,0,0,data->w,data->h,con,data->x,data->y,1.0f,data->transparency);
}