From 55ca037411de9f669da282c1c86203862e74b029 Mon Sep 17 00:00:00 2001 From: Nathan Jeffords Date: Sun, 27 Jan 2013 11:56:00 -0800 Subject: [PATCH] Created a MyGUI widget to present a page of formatted text. --- apps/openmw/CMakeLists.txt | 2 +- apps/openmw/mwgui/bookpage.cpp | 1204 ++++++++++++++++++++++++ apps/openmw/mwgui/bookpage.hpp | 120 +++ apps/openmw/mwgui/windowmanagerimp.cpp | 2 + 4 files changed, 1327 insertions(+), 1 deletion(-) create mode 100644 apps/openmw/mwgui/bookpage.cpp create mode 100644 apps/openmw/mwgui/bookpage.hpp diff --git a/apps/openmw/CMakeLists.txt b/apps/openmw/CMakeLists.txt index f4fdcb390e..fcd2c14500 100644 --- a/apps/openmw/CMakeLists.txt +++ b/apps/openmw/CMakeLists.txt @@ -31,7 +31,7 @@ add_openmw_dir (mwgui confirmationdialog alchemywindow referenceinterface spellwindow mainmenu quickkeysmenu itemselection spellbuyingwindow loadingscreen levelupdialog waitdialog spellcreationdialog enchantingdialog trainingwindow travelwindow imagebutton exposedwindow cursor spellicons - merchantrepair repair soulgemdialog companionwindow + merchantrepair repair soulgemdialog companionwindow bookpage ) add_openmw_dir (mwdialogue diff --git a/apps/openmw/mwgui/bookpage.cpp b/apps/openmw/mwgui/bookpage.cpp new file mode 100644 index 0000000000..4007dc1f19 --- /dev/null +++ b/apps/openmw/mwgui/bookpage.cpp @@ -0,0 +1,1204 @@ +#include "bookpage.hpp" + +#include "MyGUI_FontManager.h" +#include "MyGUI_RenderItem.h" +#include "MyGUI_RenderManager.h" +#include "MyGUI_TextureUtility.h" +#include "MyGUI_FactoryManager.h" + +#include + +#include + +namespace MWGui +{ + struct TypesetBook; + struct PageDisplay; + struct BookPage; +} + +using namespace MyGUI; +using namespace MWGui; + +static bool ucs_space (int code_point); +static bool ucs_line_break (int code_point); +static bool ucs_breaking_space (int code_point); + +struct IBookTypesetter::IStyle { virtual ~IStyle () {} }; + +struct MWGui::TypesetBook : ITypesetBook +{ + typedef std::vector content; + typedef std::list contents; + typedef utf8_stream::point utf8_point; + typedef std::pair range; + + struct style : IBookTypesetter::IStyle + { + IFont* Font; + Colour HotColour; + Colour ActiveColour; + Colour NormalColour; + interactive_id InteractiveId; + + bool match (IFont* tstFont, Colour tstHotColour, Colour tstActiveColour, Colour tstNormalColour, intptr_t tstInteractiveId) + { + return (Font == tstFont) && + partal_match (tstHotColour, tstActiveColour, tstNormalColour, tstInteractiveId); + } + + bool match (char const * tstFont, Colour tstHotColour, Colour tstActiveColour, Colour tstNormalColour, intptr_t tstInteractiveId) + { + return (Font->getResourceName () == tstFont) && + partal_match (tstHotColour, tstActiveColour, tstNormalColour, tstInteractiveId); + } + + bool partal_match (Colour tstHotColour, Colour tstActiveColour, Colour tstNormalColour, intptr_t tstInteractiveId) + { + return + (HotColour == tstHotColour ) && + (ActiveColour == tstActiveColour ) && + (NormalColour == tstNormalColour ) && + (InteractiveId == tstInteractiveId ) ; + } + }; + + typedef std::list