previewable Display Picture with control of small icon
This commit is contained in:
@@ -1344,3 +1344,33 @@ void story_dialog(cUniverse& univ, std::string title, str_num_t first, str_num_t
|
||||
story_dlg["title"].setText(title);
|
||||
story_dlg.run();
|
||||
}
|
||||
|
||||
void custom_pic_dialog(std::string title, pic_num_t bigpic, pic_num_t icon) {
|
||||
cDialog pic_dlg(*ResMgr::dialogs.get("show-map"));
|
||||
cControl& okay = pic_dlg["okay"];
|
||||
cControl& text = pic_dlg["title"];
|
||||
okay.attachClickHandler(std::bind(&cDialog::toast, &pic_dlg, false));
|
||||
text.setText(title);
|
||||
|
||||
// The default small icon is a map
|
||||
if(icon < 0) icon = 21;
|
||||
cPict& icon_pict = dynamic_cast<cPict&>(pic_dlg["icon"]);
|
||||
icon_pict.setPict(icon, PIC_DLOG); // Does this allow custom?
|
||||
|
||||
cPict& map = dynamic_cast<cPict&>(pic_dlg["map"]);
|
||||
// We don't provide a way to use non-custom full sheets - why would you want to show standard help graphics?
|
||||
map.setPict(bigpic, PIC_CUSTOM_FULL);
|
||||
|
||||
// Now we need to adjust the size to ensure that everything fits correctly.
|
||||
map.recalcRect();
|
||||
rectangle mapBounds = map.getBounds();
|
||||
rectangle btnBounds = okay.getBounds();
|
||||
rectangle txtBounds = text.getBounds();
|
||||
btnBounds.offset(-btnBounds.left, -btnBounds.top);
|
||||
btnBounds.offset(mapBounds.right - btnBounds.width(), mapBounds.bottom + 10);
|
||||
okay.setBounds(btnBounds);
|
||||
txtBounds.right = mapBounds.right;
|
||||
text.setBounds(txtBounds);
|
||||
pic_dlg.recalcRect();
|
||||
pic_dlg.run();
|
||||
}
|
||||
|
@@ -396,6 +396,7 @@ public:
|
||||
void setup_dialog_pict_anim(cDialog& dialog, std::string pict_id, short anim_loops, short anim_fps);
|
||||
|
||||
void story_dialog(cUniverse& univ, std::string title, str_num_t first, str_num_t last, eSpecCtxType which_str_type, pic_num_t pic, ePicType pt, short anim_loops, int anim_fps);
|
||||
void custom_pic_dialog(std::string title, pic_num_t bigpic, pic_num_t icon);
|
||||
|
||||
// For development/debugging only.
|
||||
void preview_dialog_xml(fs::path dialog_xml);
|
||||
|
@@ -40,7 +40,7 @@ enum ePicType {
|
||||
PIC_CUSTOM_TER = 101, ///< 28x36 custom terrain graphic from the custom sheets
|
||||
PIC_CUSTOM_TER_ANIM = 102, ///< 28x36 custom animated terrain graphic from the custom sheets
|
||||
PIC_CUSTOM_MONST = 103, ///< 28x36 custom monster graphic from the custom sheets
|
||||
PIC_CUSTOM_DLOG = 104, ///< 36x36 dialog graphic drawn from two 18x26 halves in the custom sheets
|
||||
PIC_CUSTOM_DLOG = 104, ///< 36x36 dialog graphic drawn from two 18x36 halves in the custom sheets
|
||||
PIC_CUSTOM_TALK = 105, ///< 32x32 talking portrait drawn from two 16x32 halves in the custom sheets
|
||||
PIC_CUSTOM_SCEN = 106, ///< 32x32 scenario portrait loading from scenname.exr/scenario.png
|
||||
PIC_CUSTOM_ITEM = 107, ///< 28x36 custom item graphic from the custom sheets
|
||||
|
Reference in New Issue
Block a user