From 565ddc1e12f3f420fc83a52048664b35037e9fb2 Mon Sep 17 00:00:00 2001 From: twanvl Date: Tue, 7 Aug 2007 14:19:38 +0000 Subject: [PATCH] Fixed: keys without save_value caused reader to loop Fixed: first line of multi line text value could cause warnings about whitespace Fixed some copy/paste errors in choice style reading; Text viewer correctly uses mask for first line git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@604 0fc631ac-6414-0410-93d0-97cfa31319b6 --- src/data/field/choice.cpp | 4 ++-- src/data/field/choice.hpp | 4 ++-- src/data/field/text.cpp | 2 +- src/data/symbol_font.cpp | 3 +-- src/data/symbol_font.hpp | 3 +-- src/render/text/viewer.cpp | 7 ++++++- src/util/io/reader.cpp | 2 +- 7 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/data/field/choice.cpp b/src/data/field/choice.cpp index 73cd3f62..7129a81d 100644 --- a/src/data/field/choice.cpp +++ b/src/data/field/choice.cpp @@ -278,9 +278,9 @@ IMPLEMENT_REFLECTION_ENUM(ChoiceRenderStyle) { VALUE_N("checklist", RENDER_TEXT_CHECKLIST); VALUE_N("image checklist", RENDER_IMAGE_CHECKLIST); VALUE_N("both checklist", RENDER_BOTH_CHECKLIST); - VALUE_N("text list", RENDER_IMAGE_LIST); + VALUE_N("text list", RENDER_TEXT_LIST); VALUE_N("image list", RENDER_IMAGE_LIST); - VALUE_N("both list", RENDER_IMAGE_LIST); + VALUE_N("both list", RENDER_BOTH_LIST); } IMPLEMENT_REFLECTION(ChoiceStyle) { diff --git a/src/data/field/choice.hpp b/src/data/field/choice.hpp index 09e6631f..6961ac1b 100644 --- a/src/data/field/choice.hpp +++ b/src/data/field/choice.hpp @@ -119,8 +119,8 @@ enum ChoiceRenderStyle , RENDER_HIDDEN = 0x20 // don't render anything, only have a menu , RENDER_CHECKLIST = 0x100 // render as a checklist, intended for multiple choice , RENDER_LIST = 0x200 // render as a list of images/text, intended for multiple choice -, RENDER_BOTH = RENDER_TEXT | RENDER_IMAGE -, RENDER_HIDDEN_IMAGE = RENDER_HIDDEN | RENDER_IMAGE +, RENDER_BOTH = RENDER_TEXT | RENDER_IMAGE +, RENDER_HIDDEN_IMAGE = RENDER_HIDDEN | RENDER_IMAGE , RENDER_TEXT_CHECKLIST = RENDER_CHECKLIST | RENDER_TEXT , RENDER_IMAGE_CHECKLIST = RENDER_CHECKLIST | RENDER_IMAGE , RENDER_BOTH_CHECKLIST = RENDER_CHECKLIST | RENDER_BOTH diff --git a/src/data/field/text.cpp b/src/data/field/text.cpp index b680b0ce..824942ea 100644 --- a/src/data/field/text.cpp +++ b/src/data/field/text.cpp @@ -138,7 +138,7 @@ bool TextValue::update(Context& ctx) { } IMPLEMENT_REFLECTION_NAMELESS(TextValue) { - if (fieldP->save_value || tag.scripting()) REFLECT_NAMELESS(value); + if (fieldP->save_value || tag.scripting() || tag.reading()) REFLECT_NAMELESS(value); } // ----------------------------------------------------------------------------- : FakeTextValue diff --git a/src/data/symbol_font.cpp b/src/data/symbol_font.cpp index c69d5555..a3e6cd49 100644 --- a/src/data/symbol_font.cpp +++ b/src/data/symbol_font.cpp @@ -26,7 +26,7 @@ DECLARE_DYNAMIC_ARG(SymbolFont*, symbol_font_for_reading); IMPLEMENT_DYNAMIC_ARG(SymbolFont*, symbol_font_for_reading, nullptr); SymbolFont::SymbolFont() - : img_size(12), min_size(1) + : img_size(12) , spacing(1,1) , scale_text(false) , text_margin_left(0), text_margin_right(0) @@ -51,7 +51,6 @@ IMPLEMENT_REFLECTION(SymbolFont) { REFLECT_ALIAS(300, "text align", "text alignment"); REFLECT_N("image font size", img_size); - REFLECT_N("scale down to", min_size); REFLECT_N("horizontal space", spacing.width); REFLECT_N("vertical space", spacing.height); WITH_DYNAMIC_ARG(symbol_font_for_reading, this); diff --git a/src/data/symbol_font.hpp b/src/data/symbol_font.hpp index a1d62dbc..1b4f1feb 100644 --- a/src/data/symbol_font.hpp +++ b/src/data/symbol_font.hpp @@ -77,8 +77,7 @@ class SymbolFont : public Packaged { String insertSymbolCode(int menu_id) const; private: - UInt img_size; ///< Font size that the images use - UInt min_size; ///< Minimum font size + double img_size; ///< Font size that the images use RealSize spacing; ///< Spacing between sybmols (for the default font size) // writing text bool scale_text; ///< Should text be scaled down to fit in a symbol? diff --git a/src/render/text/viewer.cpp b/src/render/text/viewer.cpp index dbaac19f..0b637d7b 100644 --- a/src/render/text/viewer.cpp +++ b/src/render/text/viewer.cpp @@ -414,6 +414,11 @@ bool TextViewer::prepareLinesScale(RotatedDC& dc, const vector& chars, line.top = style.padding_top; // size of the line so far RealSize line_size(lineLeft(dc, style, 0), 0); + while (line.top < style.height && line_size.width + 1 >= style.width - style.padding_right) { + // nothing fits on this line, move down one pixel + line.top += 1; + line_size.width = lineLeft(dc, style, line.top); + } line.positions.push_back(line_size.width); // The word we are currently reading RealSize word_size; @@ -513,7 +518,7 @@ bool TextViewer::prepareLinesScale(RotatedDC& dc, const vector& chars, while (line.top < style.height && line_size.width + 1 >= style.width - style.padding_right) { // nothing fits on this line, move down one pixel line.top += 1; - line_size = RealSize(lineLeft(dc, style, line.top), 0); + line_size.width = lineLeft(dc, style, line.top); } line.positions.push_back(line_size.width); // start position } diff --git a/src/util/io/reader.cpp b/src/util/io/reader.cpp index b3286851..a7e2b03f 100644 --- a/src/util/io/reader.cpp +++ b/src/util/io/reader.cpp @@ -241,7 +241,7 @@ const String& Reader::getValue() { previous_value.clear(); bool first = true; // read all lines that are indented enough - readLine(); + readLine(true); previous_line_number = line_number; while (indent >= expected_indent && !input->Eof()) { if (!first) previous_value += _('\n');