previewable Display Picture with control of small icon
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
<?xml version='1.0' encoding='UTF-8' standalone='no'?>
|
||||
<!-- NOTE: This file should be updated to use relative positioning the next time it changes. -->
|
||||
<!-- NOTE: This dialog is NOT used for the automap. It is used by Display Picture nodes. -->
|
||||
<?xml-stylesheet href="dialog.xsl" type="text/xsl"?>
|
||||
<dialog defbtn='okay' escbtn='okay'>
|
||||
<button name='okay' type='regular' top='276' left='232'>OK</button>
|
||||
<pict type='dlog' num='21' top='6' left='6'/>
|
||||
<pict name='icon' type='dlog' num='21' top='6' left='6'/>
|
||||
<text name='title' size='large' top='6' left='50' width='300' height='17'>Map of Somewhere:</text>
|
||||
<pict name='map' type='full' num='1400' top='28' left='50'/>
|
||||
</dialog>
|
||||
|
@@ -415,7 +415,7 @@ Unused
|
||||
Unused
|
||||
Unused
|
||||
Number of large (full-sheet) pic to display
|
||||
Unused
|
||||
Number of small icon to display (-1: a map)
|
||||
Unused
|
||||
Unused
|
||||
Unused
|
||||
|
@@ -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
|
||||
|
@@ -608,29 +608,6 @@ bool show_get_items(std::string titleText, std::vector<cItem*>& itemRefs, short
|
||||
|
||||
}
|
||||
|
||||
void custom_pic_dialog(std::string title, pic_num_t bigpic) {
|
||||
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);
|
||||
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();
|
||||
}
|
||||
|
||||
static bool get_num_of_items_event_filter(cDialog& me, std::string item_hit, eKeyMod) {
|
||||
if(item_hit == "cancel"){
|
||||
me.setResult<int>(0);
|
||||
|
@@ -24,7 +24,6 @@ void make_town_hostile();
|
||||
void set_town_attitude(short lo,short hi,eAttitude att);
|
||||
bool show_get_items(std::string titleText, std::vector<cItem*>& itemRefs, short pc_getting, bool overload = false);
|
||||
bool display_item(location from_loc,short pc_num,short mode, bool check_container);
|
||||
void custom_pic_dialog(std::string title, pic_num_t bigpic);
|
||||
short get_num_of_items(short max_num);
|
||||
void init_mini_map();
|
||||
void draw_help_dialog_item_buttons(cDialog& dialog,short item);
|
||||
|
@@ -2363,10 +2363,9 @@ void general_spec(const runtime_state& ctx) {
|
||||
}
|
||||
break;
|
||||
case eSpecType::DISPLAY_PICTURE:
|
||||
// TODO: In addition to the large picture, there's a small icon; should that be customizable?
|
||||
check_mess = false;
|
||||
univ.get_str(str1, ctx.cur_spec_type, spec.m1);
|
||||
custom_pic_dialog(str1, spec.ex1a);
|
||||
custom_pic_dialog(str1, spec.ex1a, spec.ex1b);
|
||||
break;
|
||||
case eSpecType::SDF_RANDOM:
|
||||
check_mess = true;
|
||||
|
@@ -98,11 +98,10 @@ namespace{
|
||||
.sdf()
|
||||
.sdf(eSpecField::EX1A, eSpecField::EX1B)
|
||||
.no_preview();
|
||||
// TODO implement preview
|
||||
node_properties_t S_PICTURE = node_builder_t(eSpecType::DISPLAY_PICTURE)
|
||||
.msg1(eSpecPicker::MSG_SINGLE)
|
||||
.ex1a(PIC_FULL)
|
||||
.no_preview();
|
||||
.ex1b(PIC_DLOG);
|
||||
node_properties_t S_REST = node_builder_t(eSpecType::REST)
|
||||
.msg();
|
||||
node_properties_t S_MSG_TITLE = node_builder_t(eSpecType::TITLED_MSG)
|
||||
|
@@ -874,15 +874,19 @@ static bool preview_spec_enc_dlog(cDialog& me, std::string, cSpecial& special, s
|
||||
ePicType pic_type = PIC_SCEN;
|
||||
pic_num_t pic = scenario.intro_pic;
|
||||
|
||||
// Use dark background that the game uses:
|
||||
short defaultBackground = cDialog::defaultBackground;
|
||||
cDialog::defaultBackground = cDialog::BG_DARK;
|
||||
|
||||
switch(special.type){
|
||||
case eSpecType::DISPLAY_PICTURE:
|
||||
univ.get_str(title, cur_type, special.m1);
|
||||
custom_pic_dialog(title, special.ex1a, special.ex1b);
|
||||
break;
|
||||
case eSpecType::STORY_DIALOG:{
|
||||
std::string str1;
|
||||
univ.get_str(str1,cur_type,special.m1);
|
||||
// Use dark background that the game uses:
|
||||
short defaultBackground = cDialog::defaultBackground;
|
||||
cDialog::defaultBackground = cDialog::BG_DARK;
|
||||
story_dialog(univ, str1, special.m2, special.m3, cur_type, special.pic, ePicType(special.pictype), special.ex1c, special.ex2c);
|
||||
cDialog::defaultBackground = defaultBackground;
|
||||
}break;
|
||||
case eSpecType::ONCE_GIVE_ITEM_DIALOG:{
|
||||
std::array<short, 3> buttons = {9, 19, -1};
|
||||
@@ -909,15 +913,13 @@ static bool preview_spec_enc_dlog(cDialog& me, std::string, cSpecial& special, s
|
||||
|
||||
if(str1.empty() && str2.empty()) break;
|
||||
|
||||
// Use dark background that the game uses:
|
||||
short defaultBackground = cDialog::defaultBackground;
|
||||
cDialog::defaultBackground = cDialog::BG_DARK;
|
||||
cStrDlog dlog(str1, str2, title, pic, pic_type, &me);
|
||||
dlog->getControl("record").show();
|
||||
dlog.show();
|
||||
cDialog::defaultBackground = defaultBackground;
|
||||
}break;
|
||||
}
|
||||
|
||||
cDialog::defaultBackground = defaultBackground;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user