From ca23b2f976540ff28f9ea0d43d5279ca8bf6ec34 Mon Sep 17 00:00:00 2001 From: Celtic Minstrel Date: Sat, 6 Dec 2014 05:35:20 -0500 Subject: [PATCH] Some dialog pict fixes - Pict choice dialog didn't work for present monster graphics - Icon control is a little smarter when setting its picnum --- osx/dialogxml/dlogutil.cpp | 2 +- osx/dialogxml/pict.cpp | 14 +++++++++++++- osx/dialogxml/pict.h | 6 ++++++ 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/osx/dialogxml/dlogutil.cpp b/osx/dialogxml/dlogutil.cpp index f9aaea18..a1e9e64f 100644 --- a/osx/dialogxml/dlogutil.cpp +++ b/osx/dialogxml/dlogutil.cpp @@ -26,9 +26,9 @@ const size_t cPictChoice::per_page = 36; cPictChoice::cPictChoice(std::vector& pics,ePicType t,cDialog* parent) : cPictChoice(pics.begin(), pics.end(), t, parent) {} cPictChoice::cPictChoice(std::vector>& pics,cDialog* parent) : dlg("choose-pict.xml",parent) { - attachHandlers(); picts = pics; sort(picts.begin(),picts.end()); + attachHandlers(); } cPictChoice::cPictChoice( diff --git a/osx/dialogxml/pict.cpp b/osx/dialogxml/pict.cpp index 1368801c..352c0e68 100644 --- a/osx/dialogxml/pict.cpp +++ b/osx/dialogxml/pict.cpp @@ -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(){ diff --git a/osx/dialogxml/pict.h b/osx/dialogxml/pict.h index e172a240..7cf3c6ca 100644 --- a/osx/dialogxml/pict.h +++ b/osx/dialogxml/pict.h @@ -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.