//.........这里部分代码省略.........
/* Highlight "shower" */
if (shower[0])
{
const char *str = lc_buf;
/* Display matches */
while ((str = strstr(str, shower)) != NULL)
{
int len = strlen(shower);
/* Display the match */
Term_putstr(str-lc_buf, i+2, len, TERM_YELLOW, &buf[str-lc_buf]);
/* Advance */
str += len;
}
}
/* Count the printed lines */
i++;
}
/* Hack -- failed search */
if (find)
{
bell("Search string not found!");
line = back;
find = NULL;
continue;
}
/* Show a general "title" */
prt(format("[%s, %s, Line %d-%d/%d]", buildid,
caption, line, line + hgt - 4, size), 0, 0);
/* Prompt -- menu screen */
if (menu)
{
/* Wait for it */
prt("[Press a Letter, or ESC to exit.]", hgt - 1, 0);
}
/* Prompt -- small files */
else if (size <= hgt - 4)
{
/* Wait for it */
prt("[Press ESC to exit.]", hgt - 1, 0);
}
/* Prompt -- large files */
else
{
/* Wait for it */
prt("[Press Space to advance, or ESC to exit.]", hgt - 1, 0);
}
/* Get a keypress */
ch = inkey();
/* Exit the help */
if (ch.code == '?') break;
/* Toggle case sensitive on/off */
if (ch.code == '!')
开发者ID:bscottm,项目名称:angband,代码行数:67,代码来源:files.c
示例2: textui_get_item
//.........这里部分代码省略.........
int ne = 0;
/* If inven or equip is on the main screen, and only one of them
* is slated for a subwindow, we should show the opposite there */
for (j = 0; j < ANGBAND_TERM_MAX; j++) {
/* Unused */
if (!angband_term[j]) continue;
/* Count windows displaying inven */
if (window_flag[j] & (PW_INVEN)) ni++;
/* Count windows displaying equip */
if (window_flag[j] & (PW_EQUIP)) ne++;
}
/* Are we in the situation where toggling makes sense? */
if ((ni && !ne) || (!ni && ne)) {
if (player->upkeep->command_wrk == USE_EQUIP) {
if ((ne && !toggle) || (ni && toggle)) {
/* Main screen is equipment, so is subwindow */
toggle_inven_equip();
toggle = !toggle;
}
} else if (player->upkeep->command_wrk == USE_INVEN) {
if ((ni && !toggle) || (ne && toggle)) {
/* Main screen is inventory, so is subwindow */
toggle_inven_equip();
toggle = !toggle;
}
} else {
/* Quiver or floor, go back to the original */
if (toggle) {
toggle_inven_equip();
toggle = !toggle;
}
}
}
/* Redraw */
player->upkeep->redraw |= (PR_INVEN | PR_EQUIP);
/* Redraw windows */
redraw_stuff(player);
/* Save screen */
screen_save();
/* Build object list */
wipe_obj_list();
if (player->upkeep->command_wrk == USE_INVEN)
build_obj_list(i2, player->upkeep->inven, tester_m, olist_mode);
else if (player->upkeep->command_wrk == USE_EQUIP)
build_obj_list(e2, NULL, tester_m, olist_mode);
else if (player->upkeep->command_wrk == USE_QUIVER)
build_obj_list(q2, player->upkeep->quiver, tester_m,olist_mode);
else if (player->upkeep->command_wrk == USE_FLOOR)
build_obj_list(f2, floor_list, tester_m, olist_mode);
/* Show the prompt */
menu_header();
if (pmt) {
prt(pmt, 0, 0);
prt(header, 0, strlen(pmt) + 1);
}
/* No menu change request */
newmenu = FALSE;
/* Get an item choice */
*choice = item_menu(cmd, MAX(strlen(pmt), 15), mode);
/* Fix the screen */
screen_load();
/* Update */
player->upkeep->redraw |= (PR_INVEN | PR_EQUIP);
redraw_stuff(player);
/* Clear the prompt line */
prt("", 0, 0);
/* We have a selection, or are backing out */
if (*choice || !newmenu) {
if (toggle) toggle_inven_equip();
break;
}
}
} else {
/* Warning if needed */
if (str) msg("%s", str);
*choice = NULL;
}
/* Clean up */
player->upkeep->command_wrk = 0;
mem_free(floor_list);
/* Result */
return (*choice != NULL) ? TRUE : FALSE;
}
/**
* Menu command: view character dump and inventory.
*/
static void death_info(const char *title, int row)
{
struct store *home = &stores[STORE_HOME];
screen_save();
/* Display player */
display_player(0);
/* Prompt for inventory */
prt("Hit any key to see more information: ", 0, 0);
/* Allow abort at this point */
(void)anykey();
/* Show equipment and inventory */
/* Equipment -- if any */
if (player->upkeep->equip_cnt) {
Term_clear();
show_equip(OLIST_WEIGHT | OLIST_SEMPTY, NULL);
prt("You are using: -more-", 0, 0);
(void)anykey();
}
/* Inventory -- if any */
if (player->upkeep->inven_cnt) {
Term_clear();
show_inven(OLIST_WEIGHT, NULL);
prt("You are carrying: -more-", 0, 0);
(void)anykey();
}
/* Home -- if anything there */
if (home->stock) {
int page;
struct object *obj = home->stock;
/* Display contents of the home */
for (page = 1; obj; page++) {
int line;
/* Clear screen */
Term_clear();
/* Show 12 items */
for (line = 0; obj && line < 12; obj = obj->next, line++) {
byte attr;
char o_name[80];
char tmp_val[80];
/* Print header, clear line */
strnfmt(tmp_val, sizeof(tmp_val), "%c) ", I2A(line));
prt(tmp_val, line + 2, 4);
/* Get the object description */
object_desc(o_name, sizeof(o_name), obj,
ODESC_PREFIX | ODESC_FULL);
/* Get the inventory color */
attr = obj->kind->base->attr;
/* Display the object */
c_put_str(attr, o_name, line + 2, 7);
}
/* Caption */
prt(format("Your home contains (page %d): -more-", page), 0, 0);
/* Wait for it */
(void)anykey();
}
}
screen_load();
}
/**
* Try to create an item again. Output some statistics. -Bernd-
*
* The statistics are correct now. We acquire a clean grid, and then
* repeatedly place an object in this grid, copying it into an item
* holder, and then deleting the object. We fiddle with the artifact
* counter flags to prevent weirdness. We use the items to collect
* statistics on item creation relative to the initial item.
*/
static void wiz_statistics(object_type * o_ptr)
{
long i, matches, better, worse, other;
struct keypress ch;
char *quality;
bool good, great;
object_type *i_ptr;
object_type object_type_body;
const char *q =
"Rolls: %ld, Matches: %ld, Better: %ld, Worse: %ld, Other: %ld";
/* Mega-Hack -- allow multiple artifacts XXX XXX XXX */
if (artifact_p(o_ptr))
a_info[o_ptr->name1].created = FALSE;
/* Interact */
while (TRUE) {
const char *pmt =
"Roll for [n]ormal, [g]ood, or [e]xcellent treasure? ";
/* Display item */
wiz_display_item(o_ptr);
/* Get choices */
if (!get_com(pmt, &ch))
break;
if (ch.code == 'n' || ch.code == 'N') {
good = FALSE;
great = FALSE;
quality = "normal";
} else if (ch.code == 'g' || ch.code == 'G') {
good = TRUE;
great = FALSE;
quality = "good";
} else if (ch.code == 'e' || ch.code == 'E') {
good = TRUE;
great = TRUE;
quality = "excellent";
} else {
good = FALSE;
great = FALSE;
break;
}
/* Let us know what we are doing */
msg("Creating a lot of %s items. Base level = %d.", quality,
p_ptr->danger);
message_flush();
/* Set counters to zero */
matches = better = worse = other = 0;
/* Let's rock and roll */
for (i = 0; i <= TEST_ROLL; i++) {
/* Output every few rolls */
if ((i < 100) || (i % 100 == 0)) {
struct keypress kp;
/* Do not wait */
inkey_scan = SCAN_INSTANT;
/* Allow interupt */
kp = inkey();
if (kp.type != EVT_NONE) {
flush();
break;
}
/* Dump the stats */
prt(format(q, i, matches, better, worse, other), 0, 0);
Term_fresh();
}
/* Get local object */
i_ptr = &object_type_body;
/* Wipe the object */
object_wipe(i_ptr);
/* Create an object */
make_object(i_ptr, good, great, FALSE);
//.........这里部分代码省略.........
/*
* Specify tval and sval (type and subtype of object) originally
* by RAK, heavily modified by -Bernd-
*
* This function returns the k_idx of an object type, or zero if failed
*
* List up to 50 choices in three columns
*/
static int wiz_create_itemtype(void)
{
int i, num, max_num;
int col, row;
int tval;
cptr tval_desc;
char ch;
int choice[80];
char buf[160];
/* Clear screen */
Term_clear();
/* Print all tval's and their descriptions */
for (num = 0; (num < 80) && tvals[num].tval; num++)
{
row = 2 + (num % 20);
col = 20 * (num / 20);
ch = listsym[num];
prt(format("[%c] %s", ch, tvals[num].desc), row, col);
}
/* Me need to know the maximal possible tval_index */
max_num = num;
/* Choose! */
if (!get_com("Get what type of object? ", &ch, FALSE)) return (0);
/* Analyze choice */
for (num = 0; num < max_num; num++)
{
if (listsym[num] == ch) break;
}
/* Bail out if choice is illegal */
if ((num < 0) || (num >= max_num)) return (0);
/* Base object type chosen, fill in tval */
tval = tvals[num].tval;
tval_desc = tvals[num].desc;
/*** And now we go for k_idx ***/
/* Clear screen */
Term_clear();
/* We have to search the whole itemlist. */
for (num = 0, i = 1; (num < 80) && (i < max_k_idx); i++)
{
object_kind *k_ptr = &k_info[i];
/* Analyze matching items */
if (k_ptr->tval == tval)
{
/* Prepare it */
row = 2 + (num % 20);
col = 20 * (num / 20);
ch = listsym[num];
strcpy(buf," ");
/* Acquire the "name" of object "i" */
strip_name(buf, i);
/* Print it */
prt(format("[%c] %s", ch, buf), row, col);
/* Remember the object index */
choice[num++] = i;
}
}
/* Me need to know the maximal possible remembered object_index */
max_num = num;
/* Choose! */
if (!get_com(format("What Kind of %s? ", tval_desc), &ch, FALSE)) return (0);
/* Analyze choice */
for (num = 0; num < max_num; num++)
{
if (listsym[num] == ch) break;
}
/* Bail out if choice is "illegal" */
if ((num < 0) || (num >= max_num)) return (0);
/* And return successful */
//.........这里部分代码省略.........
void
logdump(void)
{
int i, count, down;
struct log_entry *lp;
char *falloc_type[3] = {"PAST_EOF", "EXTENDING", "INTERIOR"};
prt("LOG DUMP (%d total operations):\n", logcount);
if (logcount < LOGSIZE) {
i = 0;
count = logcount;
} else {
i = logptr;
count = LOGSIZE;
}
for ( ; count > 0; count--) {
int opnum;
opnum = i+1 + (logcount/LOGSIZE)*LOGSIZE;
prt("%d(%3d mod 256): ", opnum, opnum%256);
lp = &oplog[i];
if ((closeopen = lp->operation < 0))
lp->operation = ~ lp->operation;
switch (lp->operation) {
case OP_MAPREAD:
prt("MAPREAD 0x%x thru 0x%x\t(0x%x bytes)",
lp->args[0], lp->args[0] + lp->args[1] - 1,
lp->args[1]);
if (badoff >= lp->args[0] && badoff <
lp->args[0] + lp->args[1])
prt("\t***RRRR***");
break;
case OP_MAPWRITE:
prt("MAPWRITE 0x%x thru 0x%x\t(0x%x bytes)",
lp->args[0], lp->args[0] + lp->args[1] - 1,
lp->args[1]);
if (badoff >= lp->args[0] && badoff <
lp->args[0] + lp->args[1])
prt("\t******WWWW");
break;
case OP_READ:
prt("READ 0x%x thru 0x%x\t(0x%x bytes)",
lp->args[0], lp->args[0] + lp->args[1] - 1,
lp->args[1]);
if (badoff >= lp->args[0] &&
badoff < lp->args[0] + lp->args[1])
prt("\t***RRRR***");
break;
case OP_WRITE:
prt("WRITE 0x%x thru 0x%x\t(0x%x bytes)",
lp->args[0], lp->args[0] + lp->args[1] - 1,
lp->args[1]);
if (lp->args[0] > lp->args[2])
prt(" HOLE");
else if (lp->args[0] + lp->args[1] > lp->args[2])
prt(" EXTEND");
if ((badoff >= lp->args[0] || badoff >=lp->args[2]) &&
badoff < lp->args[0] + lp->args[1])
prt("\t***WWWW");
break;
case OP_TRUNCATE:
down = lp->args[0] < lp->args[1];
prt("TRUNCATE %s\tfrom 0x%x to 0x%x",
down ? "DOWN" : "UP", lp->args[1], lp->args[0]);
if (badoff >= lp->args[!down] &&
badoff < lp->args[!!down])
prt("\t******WWWW");
break;
case OP_FALLOCATE:
/* 0: offset 1: length 2: where alloced */
prt("FALLOC 0x%x thru 0x%x\t(0x%x bytes) %s",
lp->args[0], lp->args[0] + lp->args[1],
lp->args[1], falloc_type[lp->args[2]]);
if (badoff >= lp->args[0] &&
badoff < lp->args[0] + lp->args[1])
prt("\t******FFFF");
break;
case OP_PUNCH_HOLE:
prt("PUNCH 0x%x thru 0x%x\t(0x%x bytes)",
lp->args[0], lp->args[0] + lp->args[1] - 1,
lp->args[1]);
if (badoff >= lp->args[0] && badoff <
lp->args[0] + lp->args[1])
prt("\t******PPPP");
break;
case OP_CLONE:
prt("CLONE");
break;
case OP_FLATTEN:
prt("FLATTEN");
break;
case OP_SKIPPED:
prt("SKIPPED (no operation)");
break;
default:
prt("BOGUS LOG ENTRY (operation code = %d)!",
lp->operation);
}
if (closeopen)
//.........这里部分代码省略.........
开发者ID:CzBiX,项目名称:ceph,代码行数:101,代码来源:fsx.c
示例17: wiz_statistics
/*
* Try to create an item again. Output some statistics. -Bernd-
*
* The statistics are correct now. We acquire a clean grid, and then
* repeatedly place an object in this grid, copying it into an item
* holder, and then deleting the object. We fiddle with the artifact
* counter flags to prevent weirdness. We use the items to collect
* statistics on item creation relative to the initial item.
*/
static void wiz_statistics(object_type *o_ptr)
{
u32b i, matches, better, worse, other, correct;
u32b test_roll = 1000000;
char ch;
cptr quality;
u32b mode;
object_type forge;
object_type *q_ptr;
cptr q = "Rolls: %ld Correct: %ld Matches: %ld Better: %ld Worse: %ld Other: %ld";
cptr p = "Enter number of items to roll: ";
char tmp_val[80];
/* XXX XXX XXX Mega-Hack -- allow multiple artifacts */
if (object_is_fixed_artifact(o_ptr)) a_info[o_ptr->name1].cur_num = 0;
/* Interact */
while (TRUE)
{
cptr pmt = "Roll for [n]ormal, [g]ood, or [e]xcellent treasure? ";
/* Display item */
wiz_display_item(o_ptr);
/* Get choices */
if (!get_com(pmt, &ch, FALSE)) break;
if (ch == 'n' || ch == 'N')
{
mode = 0L;
quality = "normal";
}
else if (ch == 'g' || ch == 'G')
{
mode = AM_GOOD;
quality = "good";
}
else if (ch == 'e' || ch == 'E')
{
mode = AM_GOOD | AM_GREAT;
quality = "excellent";
}
else
{
break;
}
sprintf(tmp_val, "%ld", (long int)test_roll);
if (get_string(p, tmp_val, 10)) test_roll = atol(tmp_val);
test_roll = MAX(1, test_roll);
/* Let us know what we are doing */
msg_format("Creating a lot of %s items. Base level = %d.",
quality, dun_level);
msg_print(NULL);
/* Set counters to zero */
correct = matches = better = worse = other = 0;
/* Let's rock and roll */
for (i = 0; i <= test_roll; i++)
{
/* Output every few rolls */
if ((i < 100) || (i % 100 == 0))
{
/* Do not wait */
inkey_scan = TRUE;
/* Allow interupt */
if (inkey())
{
/* Flush */
flush();
/* Stop rolling */
break;
}
/* Dump the stats */
prt(format(q, i, correct, matches, better, worse, other), 0, 0);
Term_fresh();
}
//.........这里部分代码省略.........
请发表评论