当前位置: 首页>>代码示例>>C++>>正文


C++ Term_putstr函数代码示例

本文整理汇总了C++中Term_putstr函数的典型用法代码示例。如果您正苦于以下问题:C++ Term_putstr函数的具体用法?C++ Term_putstr怎么用?C++ Term_putstr使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了Term_putstr函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: display_panel

void display_panel(const data_panel *panel, int count, bool left_adj, const region *bounds)
{
	int i;
	char buffer[50];
	int col = bounds->col;
	int row = bounds->row;
	int w = bounds->width;
	int offset = 0;
	if (left_adj)
	{
		for (i = 0; i < count; i++)
		{
			int len = panel[i].label ? strlen(panel[i].label) : 0;
			if (offset < len) offset = len;
		}
		offset += 2;
	}

	for (i = 0; i < count; i++, row++)
	{
		int len;
		if (!panel[i].label) continue;
		Term_putstr(col, row, strlen(panel[i].label), TERM_WHITE, panel[i].label);

		strnfmt(buffer, sizeof(buffer), panel[i].fmt, panel[i].value[0], panel[i].value[1]);

		len = strlen(buffer);
		len = len < w - offset ? len : w - offset - 1;
		if (left_adj)
			Term_putstr(col+offset, row, len, panel[i].color, buffer);
		else
			Term_putstr(col+w-len, row, len, panel[i].color, buffer);
	}
}
开发者ID:NickMcConnell,项目名称:OangbandU,代码行数:34,代码来源:z-type.c

示例2: get_sex

/*
 * Get the Sex.
 */
static bool get_sex(void)
{
	char query2;
	int loopagain = TRUE;
	
	// Set the default sex info to female
	if (p_ptr->psex == SEX_UNDEFINED)
	{
		p_ptr->psex = SEX_FEMALE;
		sp_ptr = &sex_info[SEX_FEMALE];
	}
	
	while (loopagain == TRUE)
	{
		/* Display the player */
		display_player(0);

		// Highlight the relevant feature
		c_put_str(TERM_YELLOW, sp_ptr->title, 3, 8);
		
		/* Prompt */
		Term_putstr(QUESTION_COL, INSTRUCT_ROW + 1, -1, TERM_SLATE,
					"Enter accept sex");
		Term_putstr(QUESTION_COL, INSTRUCT_ROW + 2, -1, TERM_SLATE,
					"Space change sex");
		
		/* Hack - highlight the key names */
		Term_putstr(QUESTION_COL, INSTRUCT_ROW + 1, - 1, TERM_L_WHITE, "Enter");
		Term_putstr(QUESTION_COL, INSTRUCT_ROW + 2, - 1, TERM_L_WHITE, "Space");
		
		/* Move the cursor */
		Term_gotoxy(0, INSTRUCT_ROW + 1);
				
		/* Query */
		query2 = inkey();
		
		if ((query2 == '\r') || (query2 == '\n'))
		{
			/* got a sex*/
			loopagain = FALSE;
			
			p_ptr->redraw |= (PR_MISC);
		}
		
		else if (query2 == ESCAPE)  return (FALSE);
		
		else if (((query2 == 'Q') || (query2 == 'q')) && (turn == 0)) quit (NULL);

		else
		{
			if (p_ptr->psex == SEX_FEMALE)	p_ptr->psex = SEX_MALE;
			else							p_ptr->psex = SEX_FEMALE;
			
			sp_ptr = &sex_info[p_ptr->psex];
		}
	}
	
	return (TRUE);
}
开发者ID:halfsickofshadows,项目名称:Sil,代码行数:62,代码来源:birth.c

示例3: askfor_aux

/**
 * Get some input at the cursor location.
 *
 * The buffer is assumed to have been initialized to a default string.
 * Note that this string is often "empty" (see below).
 *
 * The default buffer is displayed in yellow until cleared, which happens
 * on the first keypress, unless that keypress is Return.
 *
 * Normal chars clear the default and append the char.
 * Backspace clears the default or deletes the final char.
 * Return accepts the current buffer contents and returns true.
 * Escape clears the buffer and the window and returns false.
 *
 * Note that 'len' refers to the size of the buffer.  The maximum length
 * of the input is 'len-1'.
 *
 * 'keypress_h' is a pointer to a function to handle keypresses, altering
 * the input buffer, cursor position and suchlike as required.  See
 * 'askfor_aux_keypress' (the default handler if you supply NULL for
 * 'keypress_h') for an example.
 */
bool askfor_aux(char *buf, size_t len, bool (*keypress_h)(char *, size_t, size_t *, size_t *, struct keypress, bool))
{
    int y, x;

    size_t k = 0;		/* Cursor position */
    size_t nul = 0;		/* Position of the null byte in the string */

    struct keypress ch = KEYPRESS_NULL;

    bool done = false;
    bool firsttime = true;

    if (keypress_h == NULL)
        keypress_h = askfor_aux_keypress;

    /* Locate the cursor */
    Term_locate(&x, &y);

    /* Paranoia */
    if ((x < 0) || (x >= 80)) x = 0;

    /* Restrict the length */
    if (x + len > 80) len = 80 - x;

    /* Truncate the default entry */
    buf[len-1] = '\0';

    /* Get the position of the null byte */
    nul = strlen(buf);

    /* Display the default answer */
    Term_erase(x, y, (int)len);
    Term_putstr(x, y, -1, COLOUR_YELLOW, buf);

    /* Process input */
    while (!done) {
        /* Place cursor */
        Term_gotoxy(x + k, y);

        /* Get a key */
        ch = inkey();

        /* Let the keypress handler deal with the keypress */
        done = keypress_h(buf, len, &k, &nul, ch, firsttime);

        /* Update the entry */
        Term_erase(x, y, (int)len);
        Term_putstr(x, y, -1, COLOUR_WHITE, buf);

        /* Not the first time round anymore */
        firsttime = false;
    }

    /* Done */
    return (ch.code != ESCAPE);
}
开发者ID:pete-mack,项目名称:angband,代码行数:78,代码来源:ui-input.c

示例4: handle_signal_abort

/*
 * Handle signal -- abort, kill, etc
 */
static void handle_signal_abort(int sig)
{
	/* Disable handler */
	(void)(*signal_aux)(sig, SIG_IGN);


	/* Nothing to save, just quit */
	if (!character_generated || character_saved) quit(NULL);


	/* Clear the bottom line */
	Term_erase(0, 23, 255);

	/* Give a warning */
	Term_putstr(0, 23, -1, TERM_RED,
	            "A gruesome software bug LEAPS out at you!");

	/* Message */
	Term_putstr(45, 23, -1, TERM_RED, "Panic save...");

	/* Flush output */
	Term_fresh();

	/* Panic Save
	p_ptr->panic_save = 1; */

	/* Panic save */
	my_strcpy(p_ptr->died_from, "(panic save)", sizeof(p_ptr->died_from));

	/* Forbid suspend */
	signals_ignore_tstp();

	/* Attempt to save */
	if (old_save())
	{
		Term_putstr(45, 23, -1, TERM_RED, "Panic save succeeded!");
	}

	/* Save failed */
	else
	{
		Term_putstr(45, 23, -1, TERM_RED, "Panic save failed!");
	}

	/* Flush output */
	Term_fresh();

	/* Quit */
	quit("software bug");
}
开发者ID:artes-liberales,项目名称:FAangband,代码行数:53,代码来源:signals.c

示例5: prt_mana

/**
 * Redraw the "monster mana bar"
 *
 * The "monster mana bar" provides visual feedback on the "mana"
 * of the monster currently being "tracked".  It follows the lead of the 
 * monster health bar for who to track.
 */
static void prt_mana(int row, int col)
{
    byte attr = TERM_SLATE;

    /* Not tracking */
    if (!p_ptr->health_who) {
	/* Erase the health bar */
	Term_erase(col, row, 12);
    }

    /* Tracking an unseen, hallucinatory, or dead monster */
    else if ((!m_list[p_ptr->health_who].ml) ||	/* Unseen */
	     (p_ptr->timed[TMD_IMAGE]) ||	/* Hallucination */
	     (m_list[p_ptr->health_who].hp < 0)) {	/* Dead (?) */
	/* The monster mana is "unknown" */
	Term_putstr(col, row, 12, attr, "[----------]");
    }

    /* Tracking a visible monster */
    else {
	int pct, len;

	monster_type *m_ptr = &m_list[p_ptr->health_who];
	monster_race *r_ptr = &r_info[m_ptr->r_idx];

	/* no mana, stop here */
	if (!r_ptr->mana) {
	    /* Erase the mana bar */
	    Term_erase(col, row, 12);

	    return;
	}

	attr = monster_mana_attr();

	/* Extract the "percent" of mana */
	pct = 100L * m_ptr->mana / r_ptr->mana;

	/* Convert percent into "mana" */
	len = (pct < 10) ? 1 : (pct < 90) ? (pct / 10 + 1) : 10;

	/* Default to "unknown" */
	Term_putstr(col, row, 12, TERM_WHITE, "[----------]");

	/* Dump the current "mana" (use '*' symbols) */
	Term_putstr(col + 1, row, len, attr, "**********");
    }
}
开发者ID:artes-liberales,项目名称:FAangband,代码行数:55,代码来源:xtra3.c

示例6: display_snipe_list

/*! 
 * @brief スナイパーの技能リストを表示する
 * @return なし
 */
void display_snipe_list(void)
{
	int             i;
	int             y = 1;
	int             x = 1;
	int             plev = p_ptr->lev;
	snipe_power     spell;
	char            psi_desc[80];

	/* Display a list of spells */
	prt("", y, x);
#ifdef JP
	put_str("名前", y, x + 5);
	put_str("Lv   MP", y, x + 35);
#else
	put_str("Name", y, x + 5);
	put_str("Lv Mana", y, x + 35);
#endif

	/* Dump the spells */
	for (i = 0; i < MAX_SNIPE_POWERS; i++)
	{
		/* Access the available spell */
		spell = snipe_powers[i];
		if (spell.min_lev > plev) continue;
		if (spell.mana_cost > (int)p_ptr->concent) continue;

		/* Dump the spell */
		sprintf(psi_desc, "  %c) %-30s%2d %4d",
			I2A(i), spell.name, spell.min_lev, spell.mana_cost);

		Term_putstr(x, y + i + 1, -1, TERM_WHITE, psi_desc);
	}
	return;
}
开发者ID:dis-,项目名称:hengband,代码行数:39,代码来源:snipe.c

示例7: cmd_sub_entry

/* Display an entry on a command menu */
static void cmd_sub_entry(menu_type *menu, int oid, bool cursor, int row, int col, int width)
{
	byte attr = (cursor ? TERM_L_BLUE : TERM_WHITE);
	const struct generic_command *commands = menu_priv(menu);

	(void)width;

	/* Write the description */
	Term_putstr(col, row, -1, attr, commands[oid].desc);

	/* Include keypress */
	Term_addch(attr, ' ');
	Term_addch(attr, '(');

	/* KTRL()ing a control character does not alter it at all */
	if (KTRL(commands[oid].key) == commands[oid].key)
	{
		Term_addch(attr, '^');
		Term_addch(attr, UN_KTRL(commands[oid].key));
	}
	else
	{
		Term_addch(attr, commands[oid].key);
	}

	Term_addch(attr, ')');
}
开发者ID:NickMcConnell,项目名称:RePosBand,代码行数:28,代码来源:cmd0.c

示例8: show_display

/**
* Display an entry on a command menu
*/
static void show_display(menu_type * menu, int oid, bool cursor, int row,
			 int col, int width)
{
    byte attr = (cursor ? TERM_L_BLUE : TERM_WHITE);

    /* Write the description */
    Term_putstr(col + 4, row, -1, attr, comm_descr[oid]);
}
开发者ID:mjdrinen,项目名称:FAangband,代码行数:11,代码来源:cmd-misc.c

示例9: prt_health

/**
 * Redraw the "monster health bar"
 *
 * The "monster health bar" provides visual feedback on the "health"
 * of the monster currently being "tracked".  There are several ways
 * to "track" a monster, including targetting it, attacking it, and
 * affecting it (and nobody else) with a ranged attack.  When nothing
 * is being tracked, we clear the health bar.  If the monster being
 * tracked is not currently visible, a special health bar is shown.
 */
static void prt_health(int row, int col)
{
    byte attr = monster_health_attr();

    /* Not tracking */
    if (!p_ptr->health_who) {
	/* Erase the health bar */
	Term_erase(col, row, 12);
    }

    /* Tracking an unseen, hallucinatory, or dead monster */
    else if ((!m_list[p_ptr->health_who].ml) ||	/* Unseen */
	     (p_ptr->timed[TMD_IMAGE]) ||	/* Hallucination */
	     (m_list[p_ptr->health_who].hp < 0)) {	/* Dead (?) */
	/* The monster health is "unknown" */
	Term_putstr(col, row, 12, attr, "[----------]");
    }

    /* Tracking a visible monster */
    else {
	int pct, len;

	monster_type *m_ptr = &m_list[p_ptr->health_who];

	/* Extract the "percent" of health */
	pct = 100L * m_ptr->hp / m_ptr->maxhp;

	/* Convert percent into "health" */
	len = (pct < 10) ? 1 : (pct < 90) ? (pct / 10 + 1) : 10;

	/* Default to "unknown" */
	Term_putstr(col, row, 12, TERM_WHITE, "[----------]");

	/* Dump the current "health" (handle monster stunning, confusion) */
	if (m_ptr->confused)
	    Term_putstr(col + 1, row, len, attr, "cccccccccc");
	else if (m_ptr->stunned)
	    Term_putstr(col + 1, row, len, attr, "ssssssssss");
	else
	    Term_putstr(col + 1, row, len, attr, "**********");
    }
}
开发者ID:artes-liberales,项目名称:FAangband,代码行数:52,代码来源:xtra3.c

示例10: display_panel

static void display_panel(const struct panel *p, bool left_adj,
		const region *bounds)
{
	size_t i;
	int col = bounds->col;
	int row = bounds->row;
	int w = bounds->width;
	int offset = 0;

	region_erase(bounds);

	if (left_adj) {
		for (i = 0; i < p->len; i++) {
			struct panel_line *pl = &p->lines[i];

			int len = pl->label ? strlen(pl->label) : 0;
			if (offset < len) offset = len;
		}
		offset += 2;
	}

	for (i = 0; i < p->len; i++, row++) {
		int len;
		struct panel_line *pl = &p->lines[i];

		if (!pl->label)
			continue;

		Term_putstr(col, row, strlen(pl->label), COLOUR_WHITE, pl->label);

		len = strlen(pl->value);
		len = len < w - offset ? len : w - offset - 1;

		if (left_adj)
			Term_putstr(col+offset, row, len, pl->attr, pl->value);
		else
			Term_putstr(col+w-len, row, len, pl->attr, pl->value);
	}
}
开发者ID:angband,项目名称:angband,代码行数:39,代码来源:ui-player.c

示例11: msg_flush

/*
 * Hack -- flush
 */
static void msg_flush(int x)
{
	byte a = TERM_L_BLUE;

	/* Pause for response */
	Term_putstr(x, 0, -1, a, "-more-");

	if (!OPT(auto_more))
		anykey();

	/* Clear the line */
	Term_erase(0, 0, 255);
}
开发者ID:Kilumanjaro,项目名称:angband,代码行数:16,代码来源:util.c

示例12: house_aux_hook

/*
 * Display additional information about each house during the selection.
 */
static void house_aux_hook(birth_menu c_str)
{
	int house_idx, i, adj;
	char s[128];
	byte attr;

	/* Extract the proper house index from the string. */
	for (house_idx = 0; house_idx < z_info->c_max; house_idx++)
	{
		if (!strcmp(c_str.name, c_name + c_info[house_idx].name)) break;
	}

	if (house_idx == z_info->c_max) return;

	/* Display relevant details. */
	for (i = 0; i < A_MAX; i++)
	{
		/*dump potential total stats*/
		strnfmt(s, sizeof(s), "%s", stat_names[i]);
		Term_putstr(TOTAL_AUX_COL, TABLE_ROW + i, -1, TERM_WHITE, s);

		adj = c_info[house_idx].h_adj[i] + rp_ptr->r_adj[i];
		strnfmt(s, sizeof(s), "%+d", adj);
		
		if (adj < 0)		attr = TERM_RED;
		else if (adj == 0)	attr = TERM_L_DARK;
		else if (adj == 1)	attr = TERM_GREEN;
		else if (adj == 2)	attr = TERM_L_GREEN;
		else				attr = TERM_L_BLUE;
		
		Term_putstr(TOTAL_AUX_COL + 4, TABLE_ROW + i, -1, attr, s);
	}

	/* Display the race flags */
	
	Term_putstr(TOTAL_AUX_COL, TABLE_ROW + A_MAX + 1, -1, TERM_WHITE, "                    ");
	Term_putstr(TOTAL_AUX_COL, TABLE_ROW + A_MAX + 2, -1, TERM_WHITE, "                    ");
	Term_putstr(TOTAL_AUX_COL, TABLE_ROW + A_MAX + 3, -1, TERM_WHITE, "                    ");
	Term_putstr(TOTAL_AUX_COL, TABLE_ROW + A_MAX + 4, -1, TERM_WHITE, "                    ");
	Term_putstr(TOTAL_AUX_COL, TABLE_ROW + A_MAX + 5, -1, TERM_WHITE, "                    ");
	
	print_rh_flags(p_ptr->prace,house_idx,TOTAL_AUX_COL,TABLE_ROW + A_MAX + 1);
	
}
开发者ID:halfsickofshadows,项目名称:Sil,代码行数:47,代码来源:birth.c

示例13: cmd_sub_entry

/* Display an entry on a command menu */
static void cmd_sub_entry(menu_type *menu, int oid, bool cursor, int row, int col, int width)
{
	byte attr = (cursor ? TERM_L_BLUE : TERM_WHITE);
	const struct cmd_info *commands = menu_priv(menu);

	int mode = OPT(rogue_like_commands) ? KEYMAP_MODE_ROGUE : KEYMAP_MODE_ORIG;
	struct keypress kp = { EVT_KBRD, commands[oid].key[mode] };
	char buf[16];

	/* Write the description */
	Term_putstr(col, row, -1, attr, commands[oid].desc);

	/* Include keypress */
	Term_addch(attr, ' ');
	Term_addch(attr, '(');

	/* Get readable version */
	keypress_to_readable(buf, sizeof buf, kp);
	Term_addstr(-1, attr, buf);

	Term_addch(attr, ')');
}
开发者ID:KertaLosataure,项目名称:angband,代码行数:23,代码来源:cmd-process.c

示例14: display_snipe_list

void display_snipe_list(void)
{
    int             i;
    int             y = 1;
    int             x = 1;
    int             plev = p_ptr->lev;
    snipe_power     spell;
    char            desc[80];

    prt("", y, x);
    put_str("Name", y, x + 5);
    put_str("Lv Mana", y, x + 35);

    for (i = 0; i < MAX_SNIPE_POWERS; i++)
    {
        spell = snipe_powers[i];
        if (spell.min_lev > plev) continue;
        if (spell.mana_cost > (int)p_ptr->concent) continue;
        sprintf(desc, "  %c) %-30s%2d %4d",
            I2A(i), spell.name, spell.min_lev, spell.mana_cost);
        Term_putstr(x, y + i + 1, -1, TERM_WHITE, desc);
    }
    return;
}
开发者ID:MichaelDiBernardo,项目名称:poschengband,代码行数:24,代码来源:sniper.c

示例15: race_aux_hook

/*
 * Display additional information about each race during the selection.
 */
static void race_aux_hook(birth_menu r_str)
{
	int race, i, adj;
	char s[50];
	byte attr;

	/* Extract the proper race index from the string. */
	for (race = 0; race < z_info->p_max; race++)
	{
		if (!strcmp(r_str.name, p_name + p_info[race].name)) break;
	}

	if (race == z_info->p_max) return;

	/* Display the stats */
	for (i = 0; i < A_MAX; i++)
	{
		/*dump the stats*/
		strnfmt(s, sizeof(s), "%s", stat_names[i]);
		Term_putstr(RACE_AUX_COL, TABLE_ROW + i, -1, TERM_WHITE, s);
		
		adj = p_info[race].r_adj[i];
		strnfmt(s, sizeof(s), "%+d", adj);
		
		if (adj < 0)		attr = TERM_RED;
		else if (adj == 0)	attr = TERM_L_DARK;
		else if (adj == 1)	attr = TERM_GREEN;
		else if (adj == 2)	attr = TERM_L_GREEN;
		else				attr = TERM_L_BLUE;
		
		Term_putstr(RACE_AUX_COL + 4, TABLE_ROW + i, -1, attr, s);
	}

	/* Display the race flags */
	
	Term_putstr(RACE_AUX_COL, TABLE_ROW + A_MAX + 1, -1, TERM_WHITE, "                    ");
	Term_putstr(RACE_AUX_COL, TABLE_ROW + A_MAX + 2, -1, TERM_WHITE, "                    ");
	Term_putstr(RACE_AUX_COL, TABLE_ROW + A_MAX + 3, -1, TERM_WHITE, "                    ");
	Term_putstr(RACE_AUX_COL, TABLE_ROW + A_MAX + 4, -1, TERM_WHITE, "                    ");
	
	print_rh_flags(race, 0, RACE_AUX_COL, TABLE_ROW + A_MAX + 1);
	
}
开发者ID:halfsickofshadows,项目名称:Sil,代码行数:46,代码来源:birth.c


注:本文中的Term_putstr函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。