add cancel button to 'ask about?'

This commit is contained in:
2025-05-15 12:35:01 -05:00
parent ce4a229e92
commit c325e01e92
2 changed files with 6 additions and 4 deletions

View File

@@ -1,9 +1,10 @@
<?xml version='1.0' encoding='UTF-8' standalone='no'?>
<!-- NOTE: This file should be updated to use relative positioning the next time it changes. -->
<?xml-stylesheet href="dialog.xsl" type="text/xsl"?>
<dialog defbtn='okay'>
<dialog defbtn='okay' escbtn='cancel'>
<field name='response' type='text' top='34' left='88' width='75' height='16'/>
<text name='prompt' size='large' top='6' left='55' width='141' height='16'>You respond:</text>
<pict name='pic' type='dlog' num='16' top='8' left='8'/>
<button name='cancel' type='regular' top='62' left='75'>Cancel</button>
<button name='okay' type='regular' top='62' left='146'>OK</button>
</dialog>

View File

@@ -830,9 +830,10 @@ void place_treasure(location where,short level,short loot,short mode) {
}
}
static bool get_text_response_event_filter(cDialog& me, std::string, eKeyMod) {
static bool get_text_response_event_filter(cDialog& me, std::string item_hit, eKeyMod) {
me.toast(true);
me.setResult(me["response"].getText());
if(item_hit == "cancel") me.setResult(std::string {""});
else me.setResult(me["response"].getText());
return true;
}
@@ -840,7 +841,7 @@ std::string get_text_response(std::string prompt, pic_num_t pic) {
set_cursor(sword_curs);
cDialog strPanel(*ResMgr::dialogs.get("get-response"));
strPanel.attachClickHandlers(get_text_response_event_filter, {"okay"});
strPanel.attachClickHandlers(get_text_response_event_filter, {"okay", "cancel"});
if(!prompt.empty()) {
dynamic_cast<cPict&>(strPanel["pic"]).setPict(pic);
strPanel["prompt"].setText(prompt);