diff --git a/rsrc/dialogs/drop-item-confirm.xml b/rsrc/dialogs/drop-item-confirm.xml index a72c4b47f..4a06ed99f 100644 --- a/rsrc/dialogs/drop-item-confirm.xml +++ b/rsrc/dialogs/drop-item-confirm.xml @@ -2,7 +2,7 @@ - + This item will be gone forever. Still drop it? diff --git a/rsrc/dialogs/edit-sign.xml b/rsrc/dialogs/edit-sign.xml index c25e94c30..16fc2cf1a 100644 --- a/rsrc/dialogs/edit-sign.xml +++ b/rsrc/dialogs/edit-sign.xml @@ -4,7 +4,7 @@ - Use a '|' to indicate a line break. + Use a '|' to indicate a line break. Editing Sign diff --git a/rsrc/dialogs/preferences.xml b/rsrc/dialogs/preferences.xml index 6da6fa150..7180de883 100644 --- a/rsrc/dialogs/preferences.xml +++ b/rsrc/dialogs/preferences.xml @@ -46,7 +46,7 @@ Select adjacent tiles Move the screen - (Holding Shift while using directional keys will do the opposite.) + (Holding Shift while using directional keys will do the opposite.) Miscellaneous: No Sounds Show room descriptions more than once diff --git a/rsrc/schemas/dialog.xsd b/rsrc/schemas/dialog.xsd index c349f0b4b..2dfd2bade 100644 --- a/rsrc/schemas/dialog.xsd +++ b/rsrc/schemas/dialog.xsd @@ -125,11 +125,18 @@ - - - - - + + + + + + + + + + + + @@ -179,6 +186,7 @@ + diff --git a/src/dialogxml/dialogs/dialog.cpp b/src/dialogxml/dialogs/dialog.cpp index c981d605e..01d723baa 100644 --- a/src/dialogxml/dialogs/dialog.cpp +++ b/src/dialogxml/dialogs/dialog.cpp @@ -1152,12 +1152,14 @@ void preview_dialog_xml() { fs::path dialog_xml = nav_get_rsrc({"xml"}); std::unique_ptr defn(load_dialog_defn(dialog_xml)); cDialog dialog(*defn); - // Make every control's click event close the dialog + // Make every clickable control's click event close the dialog for (auto control : dialog){ - control.second->attachClickHandler([](cDialog& me, std::string item_hit, eKeyMod mod) -> bool { - me.toast(false); - return true; - }); + try{ + control.second->attachClickHandler([](cDialog& me, std::string item_hit, eKeyMod mod) -> bool { + me.toast(false); + return true; + }); + }catch(...){} } dialog.run(); } diff --git a/src/dialogxml/widgets/control.cpp b/src/dialogxml/widgets/control.cpp index 9b480622c..c4f2ea0cc 100644 --- a/src/dialogxml/widgets/control.cpp +++ b/src/dialogxml/widgets/control.cpp @@ -535,7 +535,16 @@ bool cControl::parseAttribute(ticpp::Attribute& attr, std::string tagName, std:: if(val == "small") setFormat(TXT_SIZE, 10); else if(val == "large") setFormat(TXT_SIZE, 12); else if(val == "title") setFormat(TXT_SIZE, 18); - else throw xBadVal(tagName, name, val, attr.Row(), attr.Column(), fname); + else{ + auto err = xBadVal(tagName, name, val, attr.Row(), attr.Column(), fname); + try{ + setFormat(TXT_SIZE, std::stoi(val)); + }catch(std::invalid_argument& e){ + throw err; + }catch(std::out_of_range& e){ + throw err; + } + } return true; } if(name == "wrap" && canFormat(TXT_WRAP)) { diff --git a/src/dialogxml/widgets/message.cpp b/src/dialogxml/widgets/message.cpp index 618749180..58e67f987 100644 --- a/src/dialogxml/widgets/message.cpp +++ b/src/dialogxml/widgets/message.cpp @@ -65,6 +65,9 @@ bool cTextMsg::parseAttribute(ticpp::Attribute& attr, std::string tagName, std:: else if(val == "left") right_align = false; else throw xBadVal(tagName, attr.Name(), val, attr.Row(), attr.Column(), fname); return true; + }else if(attr.Name() == "show-pipes"){ + style.showPipes = str_to_bool(attr.Value()); + return true; } return cControl::parseAttribute(attr, tagName, fname); } @@ -130,14 +133,13 @@ void cTextMsg::calculate_layout() { } void cTextMsg::recalcRect() { + style.pointSize = textSize; + style.underline = underlined; + style.font = textFont; if(fixedWidth && fixedHeight){ calculate_layout(); return; } - TextStyle style; - style.font = textFont; - style.pointSize = textSize; - style.underline = underlined; style.lineHeight = textSize + 2; std::string test = getText(); size_t lines = 1, cur_line_chars = 0, max_line_chars = 0; diff --git a/src/doxy/mainpage.md b/src/doxy/mainpage.md index c35774770..c5532eedf 100644 --- a/src/doxy/mainpage.md +++ b/src/doxy/mainpage.md @@ -90,6 +90,7 @@ The `` tag accepts the following attributes: * `framed` - See **Common Attributes** above. Defaults to `false`. * `outline` - See **Common Attributes** above. +* `show-pipes` - If true the | character will appear literally. * `underline` - If true, the text will be underlined. * `align` - `right` or `left`. Defaults to `left`. * `fromlist`, `font`, `size`, `color`, `colour`, `def-key` - @@ -343,9 +344,7 @@ values. `bold`, `dungeon`, `maidenword`. It defaults to `bold`. The latter two options are fantasy-style scripts such as that used for the conversation screen. -* `size` - Although the dialog engine supports any font size, the XML -specification simplifies it to three keywords: `small`, `large`, and -`title`, representing 10pt, 12pt, and 18pt font, respectively. +* `size` - The point size of the text. An integer, or one of three presets: `small` (10pt), `large` (12pt), and `title` (18pt). * `color` or `colour` - This is the only truly unrestricted attribute, accepting any HTML colour code. It understands three-digit hex codes (eg `#333`, which is equivalent to `#333333`), six-digit hex codes, and the diff --git a/src/gfx/render_text.cpp b/src/gfx/render_text.cpp index e0e55a495..847595e09 100644 --- a/src/gfx/render_text.cpp +++ b/src/gfx/render_text.cpp @@ -112,7 +112,7 @@ break_info_t calculate_line_wrapping(rectangle dest_rect, std::string str, TextS for(i = 0; text_len(i) != text_len(i + 1) && i < str_len; i++) { unsigned short line_width = text_len(i) - text_len(last_line_break); if(((line_width > (dest_rect.width() - 6)) - && (last_word_break >= last_line_break)) || (str[i] == '|')) { + && (last_word_break >= last_line_break)) || (str[i] == '|' && !style.showPipes)) { if(str[i] == '|') { last_word_break = i + 1; } else if(last_line_break == last_word_break) @@ -151,7 +151,7 @@ static void win_draw_string(sf::RenderTarget& dest_window,rectangle dest_rect,st eTextMode mode = options.mode; if(mode == eTextMode::WRAP && total_width < dest_rect.width() && !options.right_align) mode = eTextMode::LEFT_TOP; - if(mode == eTextMode::LEFT_TOP && str.find('|') != std::string::npos) + if(mode == eTextMode::LEFT_TOP && !options.style.showPipes && str.find('|') != std::string::npos) mode = eTextMode::WRAP; // Special stuff @@ -164,7 +164,7 @@ static void win_draw_string(sf::RenderTarget& dest_window,rectangle dest_rect,st // to calculate_line_wrapping() or frame calculation is // broken. std::string str_with_pipes = str; - if(!options.showBreaks){ + if(!options.showBreaks && !options.style.showPipes){ for(int i=0; i < str.length(); ++i){ if(str[i] == '|') str[i] = ' '; } diff --git a/src/gfx/render_text.hpp b/src/gfx/render_text.hpp index d8663ab69..a0cba1dcf 100644 --- a/src/gfx/render_text.hpp +++ b/src/gfx/render_text.hpp @@ -31,6 +31,7 @@ enum eFont { struct TextStyle { bool italic = false, underline = false; + bool showPipes = false; eFont font = FONT_BOLD; int pointSize = 10, lineHeight = 10; sf::Color colour;