Some tweaks/fixes
- Show monster name in description of summoning item abilities (in-game and in the scenario editor) - Don't call drop special nodes when storing an item in a container - Don't use exceptions to determine whether a slot in the get window has an item in it - Fix placed items defaulting to 0 charges instead of -1 (fortunately, this didn't actually cause a bug) - Fix ability description in item dialog not updating after you edit the abilities - Fix off-by-one issues in several cases of the pick monster dialog - Show charges field in placed item dialog if the item is given the Shoot Flames enchantment - Fix enchantment field not being filled with the current value when opening the edit placed item dialog - Fix placed item dialog not updating after you set a new enchantment by editing the field (rather than using the Choose button) - (Dialog engine) Fix initial focus handler call passing wrong control ID
This commit is contained in:
@@ -225,7 +225,10 @@ static void put_item_info(cDialog& me,const cItem& s_i) {
|
||||
if(s_i.concealed) {
|
||||
me["abil"].setText("???");
|
||||
} else {
|
||||
me["abil"].setText(s_i.getAbilName());
|
||||
std::string abil = s_i.getAbilName();
|
||||
if(s_i.ability == eItemAbil::SUMMONING || s_i.ability == eItemAbil::MASS_SUMMONING)
|
||||
abil.replace(abil.find("%s"), 2, univ.scenario.scen_monsters[s_i.abil_data[1]].m_name);
|
||||
me["abil"].setText(abil);
|
||||
}
|
||||
}
|
||||
if(s_i.charges > 0)
|
||||
|
@@ -204,9 +204,10 @@ void drop_item(short pc_num,short item_num,location where_drop) {
|
||||
take_given_item = false;
|
||||
item_store.charges = how_many;
|
||||
}
|
||||
if(place_item(item_store,loc,true))
|
||||
if(place_item(item_store,loc,true)) {
|
||||
add_string_to_buf("Drop: Item put away");
|
||||
else add_string_to_buf("Drop: OK");
|
||||
spec = -1; // Don't call drop specials if it was put away
|
||||
} else add_string_to_buf("Drop: OK");
|
||||
univ.party[pc_num].items[item_num].charges -= how_many;
|
||||
if(take_given_item)
|
||||
univ.party[pc_num].take_item(item_num);
|
||||
@@ -465,9 +466,7 @@ static void put_item_graphics(cDialog& me, size_t& first_item_shown, short& curr
|
||||
key_stash[0] = 'a' + i;
|
||||
|
||||
// TODO: Rework this so that no exceptions are required
|
||||
try {
|
||||
if(item_array.at(i + first_item_shown)->variety == eItemType::NO_ITEM)
|
||||
throw std::out_of_range("");
|
||||
if(i + first_item_shown < item_array.size() && item_array[i + first_item_shown]->variety != eItemType::NO_ITEM) {
|
||||
// display an item in window
|
||||
me[pict].show();
|
||||
item = *item_array[i + first_item_shown];
|
||||
@@ -480,7 +479,7 @@ static void put_item_graphics(cDialog& me, size_t& first_item_shown, short& curr
|
||||
me[detail].setText(get_item_interesting_string(item));
|
||||
me[weight].setText("Weight: " + std::to_string(item.item_weight()));
|
||||
me[key].setText(key_stash);
|
||||
} catch(std::out_of_range) { // erase the spot
|
||||
} else { // erase the spot
|
||||
me[pict].hide();
|
||||
me[name].setText("");
|
||||
me[detail].setText("");
|
||||
|
@@ -1237,11 +1237,10 @@ std::string cItem::getAbilName() const {
|
||||
if(party) sout << " All";
|
||||
break;
|
||||
case eItemAbil::SUMMONING:
|
||||
// TODO: Figure out a way to wedge the monster name in here.
|
||||
sout << "Summons " << "monst-names";
|
||||
sout << "Summons %s";
|
||||
break;
|
||||
case eItemAbil::MASS_SUMMONING:
|
||||
sout << "Mass summon " << "monst-names";
|
||||
sout << "Mass summon %s";
|
||||
break;
|
||||
}
|
||||
return sout.str();
|
||||
|
@@ -54,8 +54,8 @@ public:
|
||||
public:
|
||||
location loc;
|
||||
short code,ability;
|
||||
int charges;
|
||||
bool always_there, property, contained;
|
||||
int charges = -1;
|
||||
bool always_there = false, property = false, contained = false;
|
||||
|
||||
void append(legacy::preset_item_type old);
|
||||
cItem();
|
||||
|
@@ -1044,7 +1044,7 @@ void cDialog::run(std::function<void(cDialog&)> onopen){
|
||||
return ctrl.second->isVisible();
|
||||
});
|
||||
if(iter != tabOrder.end()) {
|
||||
iter->second->triggerFocusHandler(*this, tabOrder[0].first, false);
|
||||
iter->second->triggerFocusHandler(*this, iter->first, false);
|
||||
currentFocus = iter->first;
|
||||
}
|
||||
}
|
||||
|
@@ -1142,7 +1142,7 @@ static bool edit_monst_abil_detail(cDialog& me, std::string hit, cMonster& monst
|
||||
case eMonstAbilTemplate::SUMMON_5:
|
||||
case eMonstAbilTemplate::SUMMON_20:
|
||||
case eMonstAbilTemplate::SUMMON_50:
|
||||
param = choose_text(STRT_MONST, 0, &me, "Summon which monster?");
|
||||
param = choose_text(STRT_MONST, 1, &me, "Summon which monster?") + 1;
|
||||
break;
|
||||
case eMonstAbilTemplate::SPECIAL:
|
||||
case eMonstAbilTemplate::HIT_TRIGGERS:
|
||||
@@ -1498,7 +1498,11 @@ static void put_item_info_in_dlog(cDialog& me, cItem& item, short which) {
|
||||
me["value"].setTextToNum(item.value);
|
||||
me["weight"].setTextToNum(item.weight);
|
||||
me["class"].setTextToNum(item.special_class);
|
||||
me["abilname"].setText(item.getAbilName());
|
||||
|
||||
std::string abil = item.getAbilName();
|
||||
if(item.ability == eItemAbil::SUMMONING || item.ability == eItemAbil::MASS_SUMMONING)
|
||||
abil.replace(abil.find("%s"), 2, scenario.scen_monsters[item.abil_data[1]].m_name);
|
||||
me["abilname"].setText(abil);
|
||||
}
|
||||
|
||||
static void save_item_info(cDialog& me, cItem& item) {
|
||||
@@ -1629,6 +1633,7 @@ static bool edit_item_type_event_filter(cDialog& me, std::string hit, cItem& ite
|
||||
temp_item = edit_item_abil(item,which,me);
|
||||
if(temp_item.variety != eItemType::NO_ITEM)
|
||||
item = temp_item;
|
||||
put_item_info_in_dlog(me, item, which);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -1836,7 +1841,7 @@ static bool edit_item_abil_event_filter(cDialog& me, std::string hit, cItem& ite
|
||||
break;
|
||||
case eItemAbil::SUMMONING:
|
||||
case eItemAbil::MASS_SUMMONING:
|
||||
i = choose_text(STRT_MONST, i, &me, "Summon which monster type?");
|
||||
i = choose_text(STRT_MONST, i - 1, &me, "Summon which monster type?") + 1;
|
||||
break;
|
||||
default: return true;
|
||||
}
|
||||
|
@@ -73,7 +73,7 @@ static bool edit_placed_monst_event_filter(cDialog& me, std::string hit, cTownpe
|
||||
town->creatures[which].number = 0;
|
||||
} else if(hit == "type-edit") {
|
||||
get_placed_monst_in_dlog(me, monst);
|
||||
i = choose_text(STRT_MONST,monst.number,&me,"Choose Which Monster:");
|
||||
i = choose_text(STRT_MONST,monst.number-1,&me,"Choose Which Monster:") + 1;
|
||||
if(i >= 0) {
|
||||
monst.number = i;
|
||||
put_placed_monst_in_dlog(me, monst, which);
|
||||
@@ -238,11 +238,11 @@ static bool put_placed_item_in_dlog(cDialog& me, const cTown::cItem& item, const
|
||||
|
||||
if(base.variety == eItemType::GOLD || base.variety == eItemType::FOOD) {
|
||||
me["charges-lbl"].setText("Amount:");
|
||||
} else if(base.charges == 0) {
|
||||
} else if(base.charges == 0 && item.ability != 3) {
|
||||
me["charges-lbl"].hide();
|
||||
me["charges"].hide();
|
||||
} else {
|
||||
me["charges-lbl"].setText("Charges:||(-1 = default)");
|
||||
me["charges-lbl"].setText("Charges:|(-1 = default)");
|
||||
}
|
||||
|
||||
if(base.variety == eItemType::ONE_HANDED || base.variety == eItemType::TWO_HANDED) {
|
||||
@@ -274,6 +274,7 @@ static bool get_placed_item_in_dlog(cDialog& me, cTown::cItem& item, const short
|
||||
item.always_there = dynamic_cast<cLed&>(me["always"]).getState() != led_off;
|
||||
item.property = dynamic_cast<cLed&>(me["owned"]).getState() != led_off;
|
||||
item.contained = dynamic_cast<cLed&>(me["contained"]).getState() != led_off;
|
||||
item.ability = me["abil"].getTextAsNum();
|
||||
|
||||
town->preset_items[which] = item;
|
||||
return true;
|
||||
@@ -288,16 +289,17 @@ static bool edit_placed_item_type(cDialog& me, cTown::cItem& item, const short w
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool edit_placed_item_abil(cDialog& me, cTown::cItem& item, const short which) {
|
||||
static bool edit_placed_item_abil(cDialog& me, std::string item_hit, cTown::cItem& item, const short which) {
|
||||
item.charges = me["charges"].getTextAsNum();
|
||||
cItem& base = scenario.scen_items[item.code];
|
||||
short i = item.ability;
|
||||
if(base.variety == eItemType::ONE_HANDED || base.variety == eItemType::TWO_HANDED) {
|
||||
if(item_hit == "abil") { // User entered a number directly
|
||||
i = me["abil"].getTextAsNum();
|
||||
} else if(base.variety == eItemType::ONE_HANDED || base.variety == eItemType::TWO_HANDED) {
|
||||
i = choose_text(STRT_ENCHANT, item.ability, &me, "Which enchantment?");
|
||||
}
|
||||
if(i >= 0) {
|
||||
item.ability = i;
|
||||
put_placed_item_in_dlog(me, item, which);
|
||||
}
|
||||
if(i >= -1) item.ability = i;
|
||||
put_placed_item_in_dlog(me, item, which);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -317,8 +319,8 @@ void edit_placed_item(short which_i) {
|
||||
item_dlg["okay"].attachClickHandler(std::bind(get_placed_item_in_dlog, _1, std::ref(item), which_i));
|
||||
item_dlg["choose"].attachClickHandler(std::bind(edit_placed_item_type, _1, std::ref(item), which_i));
|
||||
item_dlg["del"].attachClickHandler(std::bind(edit_placed_item_delete, _1, which_i));
|
||||
item_dlg["abil-choose"].attachClickHandler(std::bind(edit_placed_item_abil, _1, std::ref(item), which_i));
|
||||
item_dlg["abil"].attachFocusHandler(std::bind(put_placed_item_in_dlog, _1, std::ref(item), which_i));
|
||||
item_dlg["abil-choose"].attachClickHandler(std::bind(edit_placed_item_abil, _1, _2, std::ref(item), which_i));
|
||||
item_dlg["abil"].attachFocusHandler(std::bind(edit_placed_item_abil, _1, _2, std::ref(item), which_i));
|
||||
|
||||
put_placed_item_in_dlog(item_dlg, item, which_i);
|
||||
|
||||
@@ -576,10 +578,10 @@ static bool edit_out_wand_monst(cDialog& me, std::string hit, short which, cOutd
|
||||
std::string fld = hit.substr(7);
|
||||
short i;
|
||||
if(fld[0] == 'f') {
|
||||
i = choose_text(STRT_MONST,wand.monst[fld[3] - '0'],&me,"Choose Which Monster:");
|
||||
i = choose_text(STRT_MONST,wand.monst[fld[3] - '0']-1,&me,"Choose Which Monster:") + 1;
|
||||
if(i >= 0) wand.monst[fld[3] - '0'] = i;
|
||||
} else if(fld[0] == 'a') {
|
||||
i = choose_text(STRT_MONST,wand.friendly[fld[4] - '0'],&me,"Choose Which Monster:");
|
||||
i = choose_text(STRT_MONST,wand.friendly[fld[4] - '0']-1,&me,"Choose Which Monster:") + 1;
|
||||
if(i >= 0) wand.friendly[fld[4] - '0'] = i;
|
||||
}
|
||||
me[fld].setText(scenario.scen_monsters[i].m_name);
|
||||
@@ -828,7 +830,7 @@ static bool edit_town_wand_event_filter(cDialog& me, std::string item_hit, eKeyM
|
||||
std::string base_id = "group" + std::to_string(group) + "-monst";
|
||||
for(int i = 0; i < 4; i++) {
|
||||
std::string id = base_id + std::to_string(i + 1);
|
||||
short n = choose_text(STRT_MONST, town->wandering[group].monst[i], &me, titles[i]);
|
||||
short n = choose_text(STRT_MONST, town->wandering[group].monst[i] - 1, &me, titles[i]) + 1;
|
||||
if(n == town->wandering[group].monst[i]) break;
|
||||
me[id].setTextToNum(n);
|
||||
}
|
||||
|
Reference in New Issue
Block a user