From 2b19c80a7e1c5522538734bc7ee18a38e94d50a9 Mon Sep 17 00:00:00 2001 From: kiritow <1362050620@qq.com> Date: Thu, 13 Apr 2017 16:19:35 +0800 Subject: [PATCH 01/17] Create header and source --- MiniEngine_Xml.cpp | 1 + MiniEngine_Xml.h | 3 +++ 2 files changed, 4 insertions(+) create mode 100644 MiniEngine_Xml.cpp create mode 100644 MiniEngine_Xml.h diff --git a/MiniEngine_Xml.cpp b/MiniEngine_Xml.cpp new file mode 100644 index 0000000..7c31e77 --- /dev/null +++ b/MiniEngine_Xml.cpp @@ -0,0 +1 @@ +#include "MiniEngine_Xml.h" diff --git a/MiniEngine_Xml.h b/MiniEngine_Xml.h new file mode 100644 index 0000000..a5f1a4d --- /dev/null +++ b/MiniEngine_Xml.h @@ -0,0 +1,3 @@ +#pragma once +#include "MiniEngine.h" + From f9c2e872df47a6fc90fb0dfab43d94d15066bb22 Mon Sep 17 00:00:00 2001 From: kiritow <1362050620@qq.com> Date: Thu, 13 Apr 2017 20:28:16 +0800 Subject: [PATCH 02/17] Change rapidxml header to avoid compile errors --- rapidxml/rapidxml_print.hpp | 76 +++++++++++++++++++++++++++---------- 1 file changed, 55 insertions(+), 21 deletions(-) diff --git a/rapidxml/rapidxml_print.hpp b/rapidxml/rapidxml_print.hpp index d03d5f5..718db5f 100644 --- a/rapidxml/rapidxml_print.hpp +++ b/rapidxml/rapidxml_print.hpp @@ -28,10 +28,10 @@ namespace rapidxml //! \cond internal namespace internal { - + /////////////////////////////////////////////////////////////////////////// // Internal character operations - + // Copy characters from given range to given output iterator template inline OutIt copy_chars(const Ch *begin, const Ch *end, OutIt out) @@ -40,7 +40,7 @@ namespace rapidxml *out++ = *begin++; return out; } - + // Copy characters from given range to given output iterator and expand // characters into references (< > ' " &) template @@ -59,17 +59,17 @@ namespace rapidxml case Ch('<'): *out++ = Ch('&'); *out++ = Ch('l'); *out++ = Ch('t'); *out++ = Ch(';'); break; - case Ch('>'): + case Ch('>'): *out++ = Ch('&'); *out++ = Ch('g'); *out++ = Ch('t'); *out++ = Ch(';'); break; - case Ch('\''): + case Ch('\''): *out++ = Ch('&'); *out++ = Ch('a'); *out++ = Ch('p'); *out++ = Ch('o'); *out++ = Ch('s'); *out++ = Ch(';'); break; - case Ch('"'): + case Ch('"'): *out++ = Ch('&'); *out++ = Ch('q'); *out++ = Ch('u'); *out++ = Ch('o'); *out++ = Ch('t'); *out++ = Ch(';'); break; - case Ch('&'): - *out++ = Ch('&'); *out++ = Ch('a'); *out++ = Ch('m'); *out++ = Ch('p'); *out++ = Ch(';'); + case Ch('&'): + *out++ = Ch('&'); *out++ = Ch('a'); *out++ = Ch('m'); *out++ = Ch('p'); *out++ = Ch(';'); break; default: *out++ = *begin; // No expansion, copy character @@ -101,7 +101,41 @@ namespace rapidxml /////////////////////////////////////////////////////////////////////////// // Internal printing operations - + + /// Forward Declaration : Fix Compile Bug in MinGW + template + inline OutIt print_node(OutIt out, const xml_node *node, int flags, int indent); + + template + inline OutIt print_children(OutIt out, const xml_node *node, int flags, int indent); + + template + inline OutIt print_attributes(OutIt out, const xml_node *node, int flags); + + template + inline OutIt print_data_node(OutIt out, const xml_node *node, int flags, int indent); + + template + inline OutIt print_cdata_node(OutIt out, const xml_node *node, int flags, int indent); + + template + inline OutIt print_element_node(OutIt out, const xml_node *node, int flags, int indent); + + template + inline OutIt print_declaration_node(OutIt out, const xml_node *node, int flags, int indent); + + template + inline OutIt print_comment_node(OutIt out, const xml_node *node, int flags, int indent); + + template + inline OutIt print_doctype_node(OutIt out, const xml_node *node, int flags, int indent); + + template + inline OutIt print_pi_node(OutIt out, const xml_node *node, int flags, int indent); + + + + // Print node template inline OutIt print_node(OutIt out, const xml_node *node, int flags, int indent) @@ -119,12 +153,12 @@ namespace rapidxml case node_element: out = print_element_node(out, node, flags, indent); break; - + // Data case node_data: out = print_data_node(out, node, flags, indent); break; - + // CDATA case node_cdata: out = print_cdata_node(out, node, flags, indent); @@ -139,7 +173,7 @@ namespace rapidxml case node_comment: out = print_comment_node(out, node, flags, indent); break; - + // Doctype case node_doctype: out = print_doctype_node(out, node, flags, indent); @@ -155,7 +189,7 @@ namespace rapidxml assert(0); break; } - + // If indenting not disabled, add line break after node if (!(flags & print_no_indenting)) *out = Ch('\n'), ++out; @@ -163,8 +197,8 @@ namespace rapidxml // Return modified iterator return out; } - - // Print children of the node + + // Print children of the node template inline OutIt print_children(OutIt out, const xml_node *node, int flags, int indent) { @@ -249,7 +283,7 @@ namespace rapidxml *out = Ch('<'), ++out; out = copy_chars(node->name(), node->name() + node->name_size(), out); out = print_attributes(out, node, flags); - + // If node is childless if (node->value_size() == 0 && !node->first_node()) { @@ -308,11 +342,11 @@ namespace rapidxml // Print attributes out = print_attributes(out, node, flags); - + // Print declaration end *out = Ch('?'), ++out; *out = Ch('>'), ++out; - + return out; } @@ -384,7 +418,7 @@ namespace rapidxml //! \param node Node to be printed. Pass xml_document to print entire document. //! \param flags Flags controlling how XML is printed. //! \return Output iterator pointing to position immediately after last character of printed text. - template + template inline OutIt print(OutIt out, const xml_node &node, int flags = 0) { return internal::print_node(out, &node, flags, 0); @@ -397,7 +431,7 @@ namespace rapidxml //! \param node Node to be printed. Pass xml_document to print entire document. //! \param flags Flags controlling how XML is printed. //! \return Output stream. - template + template inline std::basic_ostream &print(std::basic_ostream &out, const xml_node &node, int flags = 0) { print(std::ostream_iterator(out), node, flags); @@ -408,7 +442,7 @@ namespace rapidxml //! \param out Output stream to print to. //! \param node Node to be printed. //! \return Output stream. - template + template inline std::basic_ostream &operator <<(std::basic_ostream &out, const xml_node &node) { return print(out, node); From b40db11955b60080aab295d8e092e75099eb27d1 Mon Sep 17 00:00:00 2001 From: kiritow <1362050620@qq.com> Date: Tue, 16 May 2017 15:23:34 +0800 Subject: [PATCH 03/17] Query of font size is supported --- MiniEngine.cpp | 22 ++++++++++++++++++++++ MiniEngine.h | 3 +++ 2 files changed, 25 insertions(+) diff --git a/MiniEngine.cpp b/MiniEngine.cpp index 283bcd6..0287cd3 100644 --- a/MiniEngine.cpp +++ b/MiniEngine.cpp @@ -1164,6 +1164,28 @@ namespace MiniEngine return 0; } + Rect Font::sizeText(const std::string& Text) throw (ErrorViewer) + { + int w=0,h=0; + if(TTF_SizeText(_get(),Text.c_str(),&w,&h)!=0) + { + /// Something might be wrong + throw ErrorViewer(); + } + return Rect(0,0,w,h); + } + + Rect Font::sizeUTF8(const std::string& Text) throw (ErrorViewer) + { + int w=0,h=0; + if(TTF_SizeUTF8(_get(),Text.c_str(),&w,&h)!=0) + { + /// Something might be wrong + throw ErrorViewer(); + } + return Rect(0,0,w,h); + } + /// rendering surfaces... Surface Font::renderText(std::string Text,RGBA fg) { diff --git a/MiniEngine.h b/MiniEngine.h index 4f09bc4..c74064e 100644 --- a/MiniEngine.h +++ b/MiniEngine.h @@ -373,6 +373,9 @@ namespace MiniEngine std::tuple