Update the edit placed item dialog

- Fix weapon enchantments
This commit is contained in:
2015-01-23 15:39:52 -05:00
parent 78cdadc13c
commit 869c629b8b
6 changed files with 78 additions and 26 deletions

View File

@@ -379,7 +379,7 @@ cItem::cItem(eAlchemy recipe) : cItem('alch') {
void cItem::enchant_weapon(eEnchant enchant_type,short new_val) {
if(magic || ability != eItemAbil::NONE)
return;
if(variety != eItemType::ONE_HANDED || variety != eItemType::TWO_HANDED)
if(variety != eItemType::ONE_HANDED && variety != eItemType::TWO_HANDED)
return;
magic = true;
enchanted = true;

View File

@@ -53,7 +53,7 @@ public:
public:
location loc;
short code,ability;
unsigned int charges;
int charges;
bool always_there, property, contained;
void append(legacy::preset_item_type old);

View File

@@ -273,6 +273,9 @@ short choose_text(eStrType list, unsigned short cur_choice, cDialog* parent, con
}
}
break;
case STRT_ENCHANT:
strings = {"+1", "+2", "+3", "Shoot Flames", "Flaming", "+5", "Blessed"};
break;
}
if(cur_choice < 0 || cur_choice >= strings.size())
cur_choice = -1;

View File

@@ -11,6 +11,7 @@ enum eStrType {
STRT_ATTITUDE, STRT_STAIR, STRT_LIGHT, STRT_CONTEXT,
STRT_SHOP, STRT_COST_ADJ, STRT_STAIR_MODE, STRT_TALK_NODE,
STRT_STATUS, STRT_SPELL_PAT, STRT_SUMMON, STRT_TALK,
STRT_ENCHANT,
};
bool cre(short val,short min,short max,std::string text1,std::string text2,cDialog* parent) ;

View File

@@ -213,13 +213,19 @@ cTownperson edit_placed_monst_adv(cTownperson initial, short which, cDialog& par
return initial;
}
static void put_placed_item_in_dlog(cDialog& me, const cTown::cItem& item, const short which) {
char str[256];
static bool put_placed_item_in_dlog(cDialog& me, const cTown::cItem& item, const short which) {
std::ostringstream loc;
cItem base = scenario.scen_items[item.code];
if(item.ability >= 0 && item.ability <= int(eEnchant::BLESSED) && (base.variety == eItemType::ONE_HANDED || base.variety == eItemType::TWO_HANDED)) {
base.enchant_weapon(eEnchant(item.ability), 0);
}
me["num"].setTextToNum(which);
sprintf(str,"X = %d, Y = %d",item.loc.x,item.loc.y);
me["loc"].setText(str);
me["name"].setText(scenario.scen_items[item.code].full_name);
loc << "X = " << item.loc.x << ", Y = " << item.loc.y;
me["loc"].setText(loc.str());
me["name"].setText(base.full_name);
me["charges"].setTextToNum(item.charges);
me["abil"].setTextToNum(item.ability);
if(item.always_there)
dynamic_cast<cLed&>(me["always"]).setState(led_red);
if(item.property)
@@ -227,7 +233,31 @@ static void put_placed_item_in_dlog(cDialog& me, const cTown::cItem& item, const
if(item.contained)
dynamic_cast<cLed&>(me["contained"]).setState(led_red);
dynamic_cast<cPict&>(me["pic"]).setPict(scenario.scen_items[item.code].graphic_num, PIC_ITEM);
dynamic_cast<cPict&>(me["pic"]).setPict(base.graphic_num, PIC_ITEM);
me["charges"].show();
me["charges-lbl"].show();
me["abil"].show();
me["abil-lbl"].show();
me["abil-choose"].show();
if(base.variety == eItemType::GOLD || base.variety == eItemType::FOOD) {
me["charges-lbl"].setText("Amount:");
} else if(base.charges == 0) {
me["charges-lbl"].hide();
me["charges"].hide();
} else {
me["charges-lbl"].setText("Charges:||(-1 = default)");
}
if(base.variety == eItemType::ONE_HANDED || base.variety == eItemType::TWO_HANDED) {
me["abil-lbl"].setText("Enchantment:");
} else {
me["abil-lbl"].hide();
me["abil"].hide();
me["abil-choose"].hide();
}
return true;
}
static bool get_placed_item_in_dlog(cDialog& me, cTown::cItem& item, const short which) {
@@ -254,7 +284,7 @@ static bool get_placed_item_in_dlog(cDialog& me, cTown::cItem& item, const short
return true;
}
static bool edit_placed_item_event_filter(cDialog& me, cTown::cItem& item, const short which) {
static bool edit_placed_item_type(cDialog& me, cTown::cItem& item, const short which) {
short i = choose_text(STRT_ITEM, item.code, &me, "Place which item?");
if(i >= 0) {
item.code = i;
@@ -263,6 +293,25 @@ static bool edit_placed_item_event_filter(cDialog& me, cTown::cItem& item, const
return true;
}
static bool edit_placed_item_abil(cDialog& me, cTown::cItem& item, const short which) {
cItem& base = scenario.scen_items[item.code];
short i = item.ability;
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);
}
return true;
}
static bool edit_placed_item_delete(cDialog& me, const short which) {
me.toast(false);
town->preset_items[which].code = -1;
return true;
}
void edit_placed_item(short which_i) {
using namespace std::placeholders;
@@ -271,7 +320,10 @@ void edit_placed_item(short which_i) {
cDialog item_dlg("edit-placed-item");
item_dlg["cancel"].attachClickHandler(std::bind(&cDialog::toast, &item_dlg, false));
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_event_filter, _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));
put_placed_item_in_dlog(item_dlg, item, which_i);