interface.
Instead of "Do you wish to inscribe this item? (y/n)" directly print "Add what to inscription? (You may also (a)utoinscribe or (c)lear it.)" (a) and (c) only where applicable, of course. This has two benefits: No extra prompt needed to inscribe anything, and I've finally managed to merge both the { prompt and inscribing from viewing into the same function. Escape or pressing Enter on an empty inscription string (or one only consisting of spaces) will return without changing anything.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@5879 c06c8d41-db1a-0410-9941-cceddc491573
4JHALUQLYAZQSH6MHLCS4EIIRHIT3Y4IYT2CE66NHSSWZFZY3SZQC
RX6575DZOHRUXQUZH34YZGPZJF4STUPLBQDIVTINA2L6LVCKRIGQC
NG53L53MSFQZAIVKHG54IEMXNJ33AYVPF2OZM4MMJFDKEJCGPBSAC
BFCFMN2BXNLXJCYYCL2V2XTDQQNM3PJPSRB6CU76FM3332NC7GMAC
MCBXXIV6GICTZB56APSXMJEI63FVQWVZR3H2DRNMMFDH2XCGK4JAC
77H4BWWPPGLM3PLZH4QTAJRXIZTSDVNCOKZE223I437FN2UJ34RQC
HQTS3VQ6PNUZKHNVEWMML7JNAAAKL4DSW3KFSRCCSLGYTDHZFCCAC
ASLW3Z5PAVZSWJEMMMVZT226P44EKSAD47QS72JIFJESAI3RPN3AC
K2CS6TCX2NDVL2ASEHGP4J4K4IJ6FP3ANNKTSIWVG43HPYSBX6ZQC
RPOZZWKG5GLPHVZZ7ZKMKS64ZMV2LDCQSARBJFJ6FZOTOKCQO7FAC
LZBHBSCXDX2JKU2BSO5QP3WDHFIGHPXK4CKUZV6FWYDRFWLQK26QC
JL3FRP7BH6VZF3T2NIPX6GHH7W2IF2DHBHHRTCHK5FEN2PDZS3HQC
IHOKNI4O7EEW4UBMKHP6XOZNEIQSW4AYOT4O3JXUIXNNR553IQAQC
IXLNOTBJGHKESBCTME6QAR6XVWFNCHYGMS62V62ZJEA7VLQHXO2QC
UWI3ZNJDRQRL7CXFNFEG46TA6SAK24XUFY5YOKVOTJA3VG3OBNFAC
7K5P2GRF6QUXTMERG2R3BB6DZFQYJQ6V2KNPMBPFDLOP36NQILPAC
KPU2SA6G7UECM5N6PNXOT5CCQAYFBN47K5JYBQMFBD25HL2A5GIAC
UCEAWJ4I6AEFR64SSUFQSX6Q62JGLMJQ5BOO5MQSV3XIE7KAS6CQC
LS5XCCGKQHSJQGWLWLGTP2F5OYWK4ND5AQQAGRN6H2HVBSXNCCZAC
IXVKL2SINZN4DMJSZSYFVK5YLGSBGV4KCN7GKYQL7SZQDCM3S7YQC
4MPLCIJZL4YNUWK2RTKNE6N4UWNBMO5WDRKW737ENVE3RKV5LCRAC
GL7TJGUGV4JPLZCDWH6QVST4RYW7UJV6IP7UAEWEKNBWJO2H2ZHAC
5YYQEHOEBH6H4FXW3H6RAQ7U6VZ33BVP3S3I3BE3GM5IUL5DAKYQC
if (longtext && wherey() <= get_number_of_lines() - 2)
{
if (autoinscribe)
{
formatted_string::parse_string(
"<cyan>So, do you wish to inscribe this item? "
"('a' to autoinscribe) ").display();
}
else
{
formatted_string::parse_string(
"<cyan>So, do you wish to inscribe this item? ").display();
}
}
// Ask a second time, if it's been a longish interruption.
if (longtext && !prompt.empty() && wherey() <= get_number_of_lines() - 2)
formatted_string::parse_string(prompt).display();
std::string ainscrip;
if (is_random_artefact(item))
ainscrip = _randart_auto_inscription(item);
// Only allow autoinscription if we don't have all the text
// already.
const bool allow_autoinscribe =
is_random_artefact(item)
&& !ainscrip.empty()
&& item.inscription.find(ainscrip) == std::string::npos;
if (allow_autoinscribe)
{
formatted_string::parse_string(
"<cyan>Do you wish to inscribe this item? "
"('a' to autoinscribe) ").display();
}
else
{
formatted_string::parse_string(
"<cyan>Do you wish to inscribe this item? ").display();
}
if (Options.tutorial_left && wherey() <= get_number_of_lines() - 5)
tutorial_inscription_info(allow_autoinscribe);
#ifdef USE_TILE
const int keyin = getch_ck();
if (toupper(keyin) == 'Y')
#else
const int keyin = getch();
if (toupper(keyin) == 'Y')
#endif
{
char buf[79];
cprintf("\nInscribe with what? ");
if (!cancelable_get_line(buf, sizeof buf))
{
item.inscription = buf;
}
}
else if (allow_autoinscribe
&& (toupper(keyin) == 'A' || keyin == CK_MOUSE_B1))
{
// Remove previous randart inscription
_trim_randart_inscrip(item);
if (!item.inscription.empty())
item.inscription += ", ";
item.inscription += ainscrip;
}
inscribe_item(item, false);
void inscribe_item(item_def &item)
// There are currently two ways to inscribe an item:
// * using the inscribe command ('{') -> proper_prompt = true
// * from the inventory when viewing an item -> proper_prompt = false
//
// Thus, proper_prompt also controls whether a tutorial explanation can be
// shown, or whether the pre- and post-inscription item names need to be
// printed.
void inscribe_item(item_def &item, bool proper_prompt)
// Only allow autoinscription if we don't have all the text
// already.
const bool autoinscribe =
is_random_artefact(item)
&& !ainscrip.empty()
&& item.inscription.find(ainscrip) == std::string::npos;
std::string prompt = (is_inscribed ? "Add what to inscription? "
: "Inscribe with what? ");
if (need_autoinscribe || is_inscribed)
{
prompt += "(You may also ";
if (need_autoinscribe)
{
prompt += "(a)utoinscribe";
if (is_inscribed)
prompt += " or ";
}
if (is_inscribed)
prompt += "(c)lear it";
prompt += ".) ";
}
if (proper_prompt)
mpr(prompt.c_str(), MSGCH_PROMPT);
else
{
prompt = "<cyan>" + prompt + "</cyan>";
formatted_string::parse_string(prompt).display();
else
item.inscription = std::string(buf);
else if (is_inscribed && buf[1] == 0
&& (buf[0] == 'c' || buf[0] == 'C'))
{
item.inscription.clear();
}
else if (strlen(buf) > 0)
{
if (is_inscribed)
item.inscription += ", ";
item.inscription += std::string(buf);
}