Some dialog pict fixes

- Pict choice dialog didn't work for present monster graphics
- Icon control is a little smarter when setting its picnum
This commit is contained in:
2014-12-06 05:35:20 -05:00
parent 8ab9d06199
commit ca23b2f976
3 changed files with 20 additions and 2 deletions

View File

@@ -26,9 +26,9 @@ const size_t cPictChoice::per_page = 36;
cPictChoice::cPictChoice(std::vector<pic_num_t>& pics,ePicType t,cDialog* parent) : cPictChoice(pics.begin(), pics.end(), t, parent) {}
cPictChoice::cPictChoice(std::vector<std::pair<pic_num_t,ePicType>>& pics,cDialog* parent) : dlg("choose-pict.xml",parent) {
attachHandlers();
picts = pics;
sort(picts.begin(),picts.end());
attachHandlers();
}
cPictChoice::cPictChoice(

View File

@@ -139,15 +139,27 @@ void cPict::setPict(pic_num_t num, ePicType type){
frame.right = frame.left + 12;
frame.bottom = frame.top + 12;
break;
case PIC_MONST:
if(picNum < 1000) {
if(m_pic_index[num].x == 2) picType += PIC_WIDE;
if(m_pic_index[num].y == 2) picType += PIC_TALL;
}
// Intentional fallthrough
default:
frame.right = frame.left + 28;
frame.bottom = frame.top + 36;
break;
}
if(picNum >= 1000) {
picNum -= 1000;
picType += PIC_CUSTOM;
}
}
void cPict::setPict(pic_num_t num) {
picNum = num;
if(picType - PIC_LARGE == PIC_MONST)
setPict(num, PIC_MONST);
else setPict(num, picType - PIC_CUSTOM);
}
pic_num_t cPict::getPicNum(){

View File

@@ -121,6 +121,12 @@ public:
/// you will need to separately update the bounding rect.
/// (The bounding rect is mostly ignored when drawing, so if the icon is opaque, the control is not clickable,
/// and there is no frame, you can usually safely skip this step.)
///
/// This function applies a few automatic adjustments to its input:
///
/// - If type is PIC_MONST, it automatically looks up the chosen icon to determine
/// whether it should apply the tall or wide modifiers.
/// - If num is 1000 or greater, it automatically subtracts 1000 and applies the custom modifier.
void setPict(pic_num_t num, ePicType type);
/// Set the pict's icon.
/// @param num The new icon index.