本文整理汇总了C++中Term_get_size函数的典型用法代码示例。如果您正苦于以下问题:C++ Term_get_size函数的具体用法?C++ Term_get_size怎么用?C++ Term_get_size使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Term_get_size函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: display_winner
/**
* Display the winner crown
*/
static void display_winner(void)
{
char buf[1024];
ang_file *fp;
int wid, hgt;
int i = 2;
int width = 0;
path_build(buf, sizeof(buf), ANGBAND_DIR_SCREENS, "crown.txt");
fp = file_open(buf, MODE_READ, FTYPE_TEXT);
Term_clear();
Term_get_size(&wid, &hgt);
if (fp) {
/* Get us the first line of file, which tells us how long the */
/* longest line is */
file_getl(fp, buf, sizeof(buf));
sscanf(buf, "%d", &width);
if (!width) width = 25;
/* Dump the file to the screen */
while (file_getl(fp, buf, sizeof(buf)))
put_str(buf, i++, (wid/2) - (width/2));
file_close(fp);
}
put_str_centred(i, 0, wid, "All Hail the Mighty Champion!");
event_signal(EVENT_INPUT_FLUSH);
pause_line(Term);
}
示例2: print_skills
/*
* Draw the skill tree
*/
void print_skills(s32b **table, s32b max, s32b sel, s32b start)
{
s32b i, j;
s32b wid, hgt;
cptr keys;
Term_clear();
Term_get_size(&wid, &hgt);
c_prt(TERM_WHITE, format("%s Skills Screen", game_module), 0, 28);
keys = format("#BEnter#W to develop a branch, #Bup#W/#Bdown#W to move, #Bright#W/#Bleft#W to modify, #B?#W for help");
display_message(0, 1, strlen(keys), TERM_WHITE, keys);
c_prt((p_ptr->skill_points) ? TERM_L_BLUE : TERM_L_RED,
format("Skill points left: %d", p_ptr->skill_points), 2, 0);
print_desc_aux(s_info[table[sel][0]].desc, 3, 0);
for (j = start; j < start + (hgt - 7); j++)
{
byte color = TERM_WHITE;
char deb = ' ', end = ' ';
if (j >= max) break;
i = table[j][0];
if (get_skill(i) == 0)
{
if (s_info[i].mod == 0) color = TERM_L_DARK;
else color = TERM_ORANGE;
}
else if (get_skill_raw(i) == SKILL_MAX) color = TERM_L_BLUE;
if (s_info[i].hidden) color = TERM_L_RED;
if (j == sel)
{
color = TERM_L_GREEN;
deb = '[';
end = ']';
}
if (!has_child(i))
{
c_prt(color, format("%c.%c%s", deb, end, s_info[i].name),
j + 7 - start, table[j][1] * 4);
}
else if (s_info[i].dev)
{
c_prt(color, format("%c-%c%s", deb, end, s_info[i].name),
j + 7 - start, table[j][1] * 4);
}
else
{
c_prt(color, format("%c+%c%s", deb, end, s_info[i].name),
j + 7 - start, table[j][1] * 4);
}
c_prt(color,
format("%c%02ld.%03ld [%01d.%03d]", (get_skill_raw(i) < 0) ? '-' : ' ',
abs(get_skill_raw(i)) / SKILL_STEP, abs(get_skill_raw(i)) % SKILL_STEP,
s_info[i].mod / 1000, s_info[i].mod % 1000),
j + 7 - start, 60);
}
}
示例3: map_panel_size
void map_panel_size(void)
{
int wid, hgt;
/* Only if the map exists */
if (!character_dungeon) return;
/* Get size */
Term_get_size(&wid, &hgt);
/* Offset */
wid -= COL_MAP + 1;
/* reset panels */
if (p_ptr->depth)
{
/* Determine number of panels (dungeon) */
max_panel_rows = max_hgt - min_hgt;
max_panel_cols = max_wid - min_wid;
}
else
{
/* Determine number of panels (wilderness) */
max_panel_rows = max_wild * 16;
max_panel_cols = max_wild * 16;
}
/* Assume illegal panel */
panel_row_min = max_panel_rows;
panel_col_min = max_panel_cols;
/* Kill previous size of line */
#ifdef USE_TRANSPARENCY
/* String of terrain characters along one row of the map */
if (mp_ta) C_KILL(mp_ta, map_wid_old, byte);
if (mp_tc) C_KILL(mp_tc, map_wid_old, char);
#endif /* USE_TRANSPARENCY */
/* String of characters along one row of the map */
if (mp_a) C_KILL(mp_a, map_wid_old, byte);
if (mp_c) C_KILL(mp_c, map_wid_old, char);
/* Save size */
map_wid_old = wid;
/* Make the new lines */
#ifdef USE_TRANSPARENCY
/* String of terrain characters along one row of the map */
C_MAKE(mp_ta, wid, byte);
C_MAKE(mp_tc, wid, char);
#endif /* USE_TRANSPARENCY */
/* String of characters along one row of the map */
C_MAKE(mp_a, wid, byte);
C_MAKE(mp_c, wid, char);
}
示例4: kingly
/*
* Change the player into a King! -RAK-
*/
void kingly(void)
{
int wid, hgt;
int cx, cy;
bool seppuku = streq(p_ptr->died_from, "Seppuku");
/* Hack -- retire in town */
dun_level = 0;
/* Fake death */
if (!seppuku)
(void)strcpy(p_ptr->died_from, "Ripe Old Age");
/* Restore the experience */
p_ptr->exp = p_ptr->max_exp;
/* Restore the level */
p_ptr->lev = p_ptr->max_plv;
Term_get_size(&wid, &hgt);
cy = hgt / 2;
cx = wid / 2;
/* Hack -- Instant Gold */
p_ptr->au += 10000000;
stats_on_gold_winnings(10000000);
/* Clear screen */
Term_clear();
/* Display a crown */
put_str("#", cy - 11, cx - 1);
put_str("#####", cy - 10, cx - 3);
put_str("#", cy - 9, cx - 1);
put_str(",,, $$$ ,,,", cy - 8, cx - 7);
put_str(",,=$ \"$$$$$\" $=,,", cy - 7, cx - 11);
put_str(",$$ $$$ $$,", cy - 6, cx - 13);
put_str("*> <*> <*", cy - 5, cx - 13);
put_str("$$ $$$ $$", cy - 4, cx - 13);
put_str("\"$$ $$$ $$\"", cy - 3, cx - 13);
put_str("\"$$ $$$ $$\"", cy - 2, cx - 12);
put_str("*#########*#########*", cy - 1, cx - 11);
put_str("*#########*#########*", cy, cx - 11);
/* Display a message */
put_str("Veni, Vidi, Vici!", cy + 3, cx - 9);
put_str("I came, I saw, I conquered!", cy + 4, cx - 14);
put_str(format("All Hail the Mighty %s!", sex_info[p_ptr->psex].winner), cy + 5, cx - 13);
/* Flush input */
flush();
/* Wait for response */
pause_line(hgt - 1);
}
示例5: increase_skill
/*
* Advance the skill point of the skill specified by i and
* modify related skills
*/
void increase_skill(s32b i, s16b *invest)
{
s32b max_skill_overage, max_level;
cptr error = NULL;
/* No skill points to be allocated */
if (!p_ptr->skill_points) return;
/* The skill cannot be increased */
if (!s_info[i].mod) return;
/* The skill is already maxed */
call_lua("get_module_info", "(s)", "d", "max_skill_level", &max_level);
if (s_info[i].value >= max_level * SKILL_STEP) return;
/* Cannot allocate more than player level + max_skill_overage levels */
call_lua("get_module_info", "(s)", "d", "max_skill_overage", &max_skill_overage);
if (((s_info[i].value + s_info[i].mod) / SKILL_STEP) >= (p_ptr->lev + max_skill_overage + 1))
{
s32b hgt, wid;
Term_get_size(&wid, &hgt);
msg_box(format("Cannot raise a skill value to or above %d until you get more experienced.", p_ptr->lev + max_skill_overage), (s32b)(hgt / 2), (s32b)(wid / 2));
return;
}
/* More complex checking */
call_lua("get_module_info", "(s,d)", "s", "allow_skill_raise", i, &error);
if (error)
{
s32b hgt, wid;
Term_get_size(&wid, &hgt);
msg_box(error, (s32b)(hgt / 2), (s32b)(wid / 2));
return;
}
/* Spend an unallocated skill point */
p_ptr->skill_points--;
/* Increase the skill */
s_info[i].value += s_info[i].mod;
invest[i]++;
}
示例6: target_display_help
/*
* Display targeting help at the bottom of the screen.
*/
static void target_display_help(bool monster, bool free)
{
/* Determine help location */
int wid, hgt, help_loc;
Term_get_size(&wid, &hgt);
help_loc = hgt - HELP_HEIGHT - (mouse_buttons ? 1 : 0);
/* Clear */
clear_from(help_loc);
/* Prepare help hooks */
text_out_hook = text_out_to_screen;
text_out_indent = 1;
Term_gotoxy(1, help_loc);
/* Display help */
text_out_c(TERM_L_GREEN, "<dir>");
text_out(" and ");
text_out_c(TERM_L_GREEN, "<click>");
text_out(" look around. '");
text_out_c(TERM_L_GREEN, "g");
text_out(" moves to the selection. '");
text_out_c(TERM_L_GREEN, "p");
text_out("' selects the player. '");
text_out_c(TERM_L_GREEN, "q");
text_out("' exits. '");
text_out_c(TERM_L_GREEN, "r");
text_out("' displays details. '");
if (free)
{
text_out_c(TERM_L_GREEN, "m");
text_out("' restricts to interesting places. ");
}
else
{
text_out_c(TERM_L_GREEN, "+");
text_out("' and '");
text_out_c(TERM_L_GREEN, "-");
text_out("' cycle through interesting places. '");
text_out_c(TERM_L_GREEN, "o");
text_out("' allows free selection. ");
}
if (monster || free)
{
text_out("'");
text_out_c(TERM_L_GREEN, "t");
text_out("' targets the current selection.");
}
/* Reset */
text_out_indent = 0;
}
示例7: print_abilities
/*
* Draw the abilities list
*/
void print_abilities(s32b table[], s32b max, s32b sel, s32b start)
{
s32b i, j;
s32b wid, hgt;
cptr keys;
Term_clear();
Term_get_size(&wid, &hgt);
c_prt(TERM_WHITE, format("%s Abilities Screen", game_module), 0, 28);
keys = format("#Bup#W/#Bdown#W to move, #Bright#W to buy, #B?#W for help");
display_message(0, 1, strlen(keys), TERM_WHITE, keys);
c_prt((p_ptr->skill_points) ? TERM_L_BLUE : TERM_L_RED,
format("Skill points left: %d", p_ptr->skill_points), 2, 0);
print_desc_aux(ab_info[table[sel]].desc, 3, 0);
for (j = start; j < start + (hgt - 7); j++)
{
byte color = TERM_WHITE;
char deb = ' ', end = ' ';
if (j >= max) break;
i = table[j];
if (ab_info[i].acquired)
color = TERM_L_BLUE;
else if (can_learn_ability(i))
color = TERM_WHITE;
else
color = TERM_L_DARK;
if (j == sel)
{
color = TERM_L_GREEN;
deb = '[';
end = ']';
}
c_prt(color, format("%c.%c%s", deb, end, ab_info[i].name),
j + 7 - start, 0);
if (!ab_info[i].acquired)
{
c_prt(color, format("%d", ab_info[i].cost), j + 7 - start, 60);
}
else
{
c_prt(color, "Known", j + 7 - start, 60);
}
}
}
示例8: _col_height
/* Yucky menu code modified from spells.c ... But I didn't want to create
a new spell object for each racial form since all we really need is the
level and the race's integer identifier.
*/
static int _col_height(int ct)
{
int w, h;
int result = ct;
Term_get_size(&w, &h);
h -= 9; /* Room for browsing */
if (result > h)
{
result = (ct + 1)/2;
}
return result;
}
示例9: update_term_size
/* プレイホストのマップが大きいときクライアントのマップもリサイズする */
static void update_term_size(int x, int y, int len)
{
int ox, oy;
int nx, ny;
Term_get_size(&ox, &oy);
nx = ox;
ny = oy;
/* 横方向のチェック */
if (x + len > ox) nx = x + len;
/* 縦方向のチェック */
if (y + 1 > oy) ny = y + 1;
if (nx != ox || ny != oy) Term_resize(nx, ny);
}
示例10: region_calculate
region region_calculate(region loc)
{
int w, h;
Term_get_size(&w, &h);
if (loc.col < 0)
loc.col += w;
if (loc.row < 0)
loc.row += w;
if (loc.width <= 0)
loc.width += w - loc.col;
if (loc.page_rows <= 0)
loc.page_rows += h - loc.row;
return loc;
}
示例11: fix_message
/*
* Hack -- display recent messages in sub-windows
*
* XXX XXX XXX Adjust for width and split messages
*/
void fix_message(void)
{
s32b j, i;
s32b w, h;
s32b x, y;
/* Scan windows */
for (j = 0; j < 8; j++)
{
term *old = Term;
/* No window */
if (!angband_term[j]) continue;
/* No relevant flags */
if (!flag_exists(&window_flag[j], FLAG_PW_MESSAGE)) continue;
/* Activate */
Term_activate(angband_term[j]);
/* Get size */
Term_get_size(&w, &h);
/* Dump messages */
for (i = 0; i < h; i++)
{
/* Dump the message on the appropriate line */
display_message(0, (h - 1) - i, strlen(message_str((s16b)i)), message_color((s16b)i), message_str((s16b)i));
/* Cursor */
Term_locate(&x, &y);
/* Clear to end of line */
Term_erase(x, y, 255);
}
/* Fresh */
Term_fresh();
/* Restore */
Term_activate(old);
}
}
示例12: update_sidebar
/*
* This prints the sidebar, using a clever method which means that it will only
* print as much as can be displayed on <24-line screens.
*
* Each row is given a priority; the least important higher numbers and the most
* important lower numbers. As the screen gets smaller, the rows start to
* disappear in the order of lowest to highest importance.
*/
static void update_sidebar(game_event_type type, game_event_data *data, void *user)
{
int x, y, row;
int max_priority;
size_t i;
Term_get_size(&x, &y);
/* Keep the top and bottom lines clear. */
max_priority = y - 2;
/* Display list entries */
for (i = 0, row = 1; i < N_ELEMENTS(side_handlers); i++)
{
const struct side_handler_t *hnd = &side_handlers[i];
int priority = hnd->priority;
bool from_bottom = FALSE;
/* Negative means print from bottom */
if (priority < 0)
{
priority = -priority;
from_bottom = TRUE;
}
/* If this is high enough priority, display it */
if (priority <= max_priority)
{
if (hnd->type == type && hnd->hook)
{
if (from_bottom)
hnd->hook(Term->hgt - (N_ELEMENTS(side_handlers) - i), 0);
else
hnd->hook(row, 0);
}
/* Increment for next time */
row++;
}
}
}
示例13: borg_term_text_comp
/* Compare what you get from borg_what_text immediately */
bool borg_term_text_comp(int x, int y, cptr what)
{
byte t_a;
int wid, hgt;
int len = strlen(what);
char buf[120];
/* Get size */
Term_get_size(&wid, &hgt);
/* That's left or right of the term */
if (x < 0 || x + len > wid) return (FALSE);
/* That's higher or lower of the term */
if (y < 0 || y >= hgt) return (FALSE);
if (0 == borg_what_text(x, y, strlen(what), &t_a, buf) &&
streq(buf, what)) return (TRUE);
/* No match */
return (FALSE);
}
示例14: gain_ability
/* Learn an ability */
static void gain_ability(s32b ab)
{
s32b wid, hgt;
Term_get_size(&wid, &hgt);
if (!can_learn_ability(ab))
{
msg_box("You cannot learn this ability.", (s32b)(hgt / 2), (s32b)(wid / 2));
return;
}
/* Flush input as we ask an important and irreversible question */
flush();
/* Ask we can commit the change */
/* if (msg_box("Learn this ability(this is permanent)? (y/n)", (s32b)(hgt / 2), (s32b)(wid / 2)) != 'y')
{
return;
}*/
ab_info[ab].acquired = TRUE;
p_ptr->skill_points -= ab_info[ab].cost;
}
示例15: display_winner
/*
* Display the winner crown
*/
static void display_winner(void)
{
char buf[1024];
ang_file *fp;
int wid, hgt;
int i = 2;
int width = 0;
path_build(buf, sizeof(buf), ANGBAND_DIR_FILE, "crown.txt");
fp = file_open(buf, MODE_READ, -1);
Term_clear();
Term_get_size(&wid, &hgt);
if (fp)
{
/* Get us the first line of file, which tells us how long the */
/* longest line is */
file_getl(fp, buf, sizeof(buf));
sscanf(buf, "%d", &width);
if (!width) width = 25;
/* Dump the file to the screen */
while (file_getl(fp, buf, sizeof(buf)))
put_str(buf, i++, (wid/2) - (width/2));
file_close(fp);
}
put_str_centred(i, 0, wid, "All Hail the Mighty %s!", p_ptr->sex->winner);
flush();
pause_line(Term);
}