1 /* ScummVM - Graphic Adventure Engine 2 * 3 * ScummVM is the legal property of its developers, whose names 4 * are too numerous to list here. Please refer to the COPYRIGHT 5 * file distributed with this source distribution. 6 * 7 * This program is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU General Public License 9 * as published by the Free Software Foundation; either version 2 10 * of the License, or (at your option) any later version. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with this program; if not, write to the Free Software 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 * 21 */ 22 23 #ifndef CRYOMNI3D_VERSAILLES_DOCUMENTATION_H 24 #define CRYOMNI3D_VERSAILLES_DOCUMENTATION_H 25 26 #include "common/hashmap.h" 27 #include "common/hash-str.h" 28 #include "common/rect.h" 29 #include "common/str-array.h" 30 #include "graphics/managed_surface.h" 31 32 namespace CryOmni3D { 33 class FontManager; 34 class MouseBoxes; 35 class Sprites; 36 37 class CryOmni3DEngine; 38 39 namespace Versailles { 40 class Versailles_Documentation { 41 public: Versailles_Documentation()42 Versailles_Documentation() : _engine(nullptr), _fontManager(nullptr), _sprites(nullptr), 43 _messages(nullptr), _linksData(nullptr), _linksSize(0), 44 _currentInTimeline(false), _currentMapLayout(false), _currentHasMap(false) { } ~Versailles_Documentation()45 ~Versailles_Documentation() { delete [] _linksData; } 46 47 void init(const Sprites *sprites, FontManager *fontManager, const Common::StringArray *messages, 48 CryOmni3DEngine *engine, const Common::String &allDocsFileName, 49 const Common::String &linksDocsFileName); 50 void handleDocArea(); 51 void handleDocInGame(const Common::String &record); 52 53 private: 54 Common::String docAreaHandleSummary(); 55 Common::String docAreaHandleTimeline(); 56 Common::String docAreaHandleGeneralMap(); 57 Common::String docAreaHandleCastleMap(); 58 uint docAreaHandleRecords(const Common::String &record); 59 60 void docAreaPrepareNavigation(); 61 void docAreaPrepareRecord(Graphics::ManagedSurface &surface, MouseBoxes &boxes); 62 uint docAreaHandleRecord(Graphics::ManagedSurface &surface, MouseBoxes &boxes, 63 Common::String &nextRecord); 64 65 void inGamePrepareRecord(Graphics::ManagedSurface &surface, MouseBoxes &boxes); 66 uint inGameHandleRecord(Graphics::ManagedSurface &surface, MouseBoxes &boxes, 67 Common::String &nextRecord); 68 69 void setupRecordBoxes(bool inDocArea, MouseBoxes &boxes); 70 void setupTimelineBoxes(MouseBoxes &boxes); 71 void drawRecordData(Graphics::ManagedSurface &surface, 72 const Common::String &text, const Common::String &title, 73 const Common::String &subtitle, const Common::String &caption); 74 void drawRecordBoxes(Graphics::ManagedSurface &surface, bool inDocArea, MouseBoxes &boxes); 75 76 uint handlePopupMenu(const Graphics::ManagedSurface &surface, 77 const Common::Point &anchor, bool rightAligned, uint itemHeight, 78 const Common::StringArray &items); 79 80 struct RecordInfo { 81 uint id; 82 uint position; 83 uint size; 84 }; 85 86 struct LinkInfo { 87 Common::String record; 88 Common::String title; 89 }; 90 91 struct TimelineEntry { 92 char year[8]; 93 uint x; 94 uint y; 95 }; 96 static const TimelineEntry kTimelineEntries[]; 97 98 char *getDocPartAddress(char *start, char *end, const char *patterns[]); 99 const char *getDocTextAddress(char *start, char *end); 100 const char *getRecordTitle(char *start, char *end); 101 const char *getRecordSubtitle(char *start, char *end); 102 const char *getRecordCaption(char *start, char *end); 103 void getRecordHyperlinks(char *start, char *end, Common::StringArray &hyperlinks); 104 105 Common::String getRecordTitle(const Common::String &record); 106 Common::String getRecordData(const Common::String &record, Common::String &title, 107 Common::String &subtitle, Common::String &caption, 108 Common::StringArray &hyperlinks); 109 void convertHyperlinks(const Common::StringArray &hyperlinks, Common::Array<LinkInfo> &links); 110 111 void loadLinksFile(); 112 void getLinks(const Common::String &record, Common::Array<LinkInfo> &links); 113 114 Common::String _allDocsFileName; 115 Common::String _linksDocsFileName; 116 117 static const uint kPopupMenuMargin = 5; 118 119 CryOmni3DEngine *_engine; 120 FontManager *_fontManager; 121 const Sprites *_sprites; 122 const Common::StringArray *_messages; 123 124 bool _multilineAttributes; 125 126 Common::StringArray _recordsOrdered; 127 Common::HashMap<Common::String, RecordInfo> _records; 128 char *_linksData; 129 uint _linksSize; 130 131 Common::Array<LinkInfo> _allLinks; 132 133 Common::StringArray _visitTrace; 134 Common::String _currentRecord; 135 Common::String _categoryStartRecord; 136 Common::String _categoryEndRecord; 137 Common::String _categoryTitle; 138 Common::Array<LinkInfo> _currentLinks; 139 bool _currentInTimeline; 140 bool _currentMapLayout; 141 bool _currentHasMap; 142 }; 143 144 } // End of namespace Versailles 145 } // End of namespace CryOmni3D 146 147 #endif 148