alchemy: try to add some information to the basic dialog (to be improved...)
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
<dialog defbtn='done'>
|
||||
<text size='large' top='10' left='54' width='163' height='15'>Alchemy known:</text>
|
||||
<pict type='dlog' num='20' top='6' left='6'/>
|
||||
<button name='done' type='done' top='174' left='356'/>
|
||||
<button name='done' type='done' top='235' left='356'/>
|
||||
<led name='potion1' state='off' top='33' left='217'/>
|
||||
<led name='potion2' state='off' top='47' left='217'/>
|
||||
<led name='potion3' state='off' top='61' left='217'/>
|
||||
@@ -28,4 +28,5 @@
|
||||
TODO: This originally had width=119; if it looks wrong in-game, try reverting to that
|
||||
-->
|
||||
<text top='179' left='8' width='250' height='16'>Number in ( ) is minimum skill to make.</text>
|
||||
<text name='info' framed='true' top='200' left='8' width='300' height='59'>Select a potion.</text>
|
||||
</dialog>
|
||||
|
@@ -291,34 +291,45 @@ extern const eItemAbil alch_ingred2[20] = {
|
||||
eItemAbil::ASPTONGUE,eItemAbil::EMBERF,eItemAbil::EMBERF,eItemAbil::ASPTONGUE,eItemAbil::EMBERF,
|
||||
};
|
||||
|
||||
static bool pick_alchemy_led(cDialog& me, std::string item_hit, bool, bool allowEdit) {
|
||||
if(item_hit.substr(0,6) != "potion")
|
||||
return false;
|
||||
int hit = item_hit[6] - '0';
|
||||
if (item_hit.size()==8)
|
||||
hit=10*hit+(item_hit[7] - '0');
|
||||
--hit;
|
||||
if (hit<0 || hit>=20)
|
||||
return false;
|
||||
if (allowEdit) {
|
||||
univ.party.alchemy[hit]=!univ.party.alchemy[hit];
|
||||
cLed& led = dynamic_cast<cLed&>(me.getControl(item_hit));
|
||||
led.setState(univ.party.alchemy[hit] ? led_red : led_off);
|
||||
}
|
||||
// TODO: change message when hit==0
|
||||
// use a variable to store the beginning of the potion details
|
||||
me["info"].setText(get_str("alchemy", hit+8));
|
||||
return true;
|
||||
}
|
||||
|
||||
void display_alchemy(bool allowEdit,cDialog* parent) {
|
||||
using namespace std::placeholders;
|
||||
set_cursor(sword_curs);
|
||||
|
||||
cChoiceDlog showAlch("pc-alchemy-info", {"done"}, parent);
|
||||
|
||||
auto led_selector = std::bind(pick_alchemy_led, _1, _2, _3, allowEdit);
|
||||
for(short i = 0; i < 20; i++) {
|
||||
std::string id = "potion" + std::to_string(i + 1);
|
||||
std::string name = get_str("magic-names", i + 200) + " (";
|
||||
name += std::to_string(alch_difficulty[i]);
|
||||
name += ')';
|
||||
showAlch->addLabelFor(id, name, LABEL_LEFT, 83, true);
|
||||
if(!allowEdit)
|
||||
showAlch->getControl(id).attachClickHandler(&cLed::noAction);
|
||||
cLed& led = dynamic_cast<cLed&>(showAlch->getControl(id));
|
||||
if(univ.party.alchemy[i])
|
||||
led.setState(led_red);
|
||||
else led.setState(led_off);
|
||||
led.attachClickHandler(led_selector);
|
||||
led.setState(univ.party.alchemy[i] ? led_red : led_off);
|
||||
}
|
||||
|
||||
showAlch.show();
|
||||
if(!allowEdit) return;
|
||||
|
||||
for(short i = 0; i < 20; i++) {
|
||||
std::string id = "potion" + std::to_string(i + 1);
|
||||
cLed& led = dynamic_cast<cLed&>(showAlch->getControl(id));
|
||||
if(led.getState() == led_red) univ.party.alchemy[i] = true;
|
||||
else univ.party.alchemy[i] = false;
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: Start spend XP dialog
|
||||
|
Reference in New Issue
Block a user