ScummVM API documentation
documentation.h
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 modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (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, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef CRYOMNI3D_VERSAILLES_DOCUMENTATION_H
23 #define CRYOMNI3D_VERSAILLES_DOCUMENTATION_H
24 
25 #include "common/hashmap.h"
26 #include "common/hash-str.h"
27 #include "common/rect.h"
28 #include "common/str-array.h"
29 #include "graphics/managed_surface.h"
30 
31 namespace CryOmni3D {
32 class FontManager;
33 class MouseBoxes;
34 class Sprites;
35 
36 namespace Versailles {
37 class CryOmni3DEngine_Versailles;
38 
40 public:
41  Versailles_Documentation() : _engine(nullptr), _fontManager(nullptr), _sprites(nullptr),
42  _messages(nullptr), _multilineAttributes(false), _linksData(nullptr), _linksSize(0),
43  _currentInTimeline(false), _currentMapLayout(false), _currentHasMap(false) { }
44  ~Versailles_Documentation() { delete [] _linksData; }
45 
46  void init(const Sprites *sprites, FontManager *fontManager, const Common::StringArray *messages,
47  CryOmni3DEngine_Versailles *engine, const Common::Path &allDocsFilePath,
48  const Common::Path &linksDocsFilePath);
49  void handleDocArea();
50  void handleDocInGame(const Common::String &record);
51 
52 private:
53  Common::String docAreaHandleSummary();
54  Common::String docAreaHandleTimeline();
55  Common::String docAreaHandleGeneralMap();
56  Common::String docAreaHandleCastleMap();
57  uint docAreaHandleRecords(const Common::String &record);
58 
59  void docAreaPrepareNavigation();
60  void docAreaPrepareRecord(Graphics::ManagedSurface &surface, MouseBoxes &boxes);
61  uint docAreaHandleRecord(Graphics::ManagedSurface &surface, MouseBoxes &boxes,
62  Common::String &nextRecord);
63 
64  void inGamePrepareRecord(Graphics::ManagedSurface &surface, MouseBoxes &boxes);
65  uint inGameHandleRecord(Graphics::ManagedSurface &surface, MouseBoxes &boxes,
66  Common::String &nextRecord);
67 
68  void setupRecordBoxes(bool inDocArea, MouseBoxes &boxes);
69  void setupTimelineBoxes(MouseBoxes &boxes);
70  void drawRecordData(Graphics::ManagedSurface &surface,
71  const Common::String &text, const Common::String &title,
72  const Common::String &subtitle, const Common::String &caption);
73  void drawRecordBoxes(Graphics::ManagedSurface &surface, bool inDocArea, MouseBoxes &boxes);
74 
75  uint handlePopupMenu(const Graphics::ManagedSurface &surface,
76  const Common::Point &anchor, bool rightAligned, uint itemHeight,
77  const Common::StringArray &items);
78 
79  struct RecordInfo {
80  uint id;
81  uint position;
82  uint size;
83  };
84 
85  struct LinkInfo {
86  Common::String record;
87  Common::String title;
88  };
89 
90  struct TimelineEntry {
91  char year[8];
92  uint x;
93  uint y;
94  };
95  static const TimelineEntry kTimelineEntries[];
96 
97  char *getDocPartAddress(char *start, char *end, const char *patterns[]);
98  const char *getDocTextAddress(char *start, char *end);
99  const char *getRecordTitle(char *start, char *end);
100  const char *getRecordSubtitle(char *start, char *end);
101  const char *getRecordCaption(char *start, char *end);
102  void getRecordHyperlinks(char *start, char *end, Common::StringArray &hyperlinks);
103 
104  Common::String getRecordTitle(const Common::String &record);
105  Common::String getRecordData(const Common::String &record, Common::String &title,
106  Common::String &subtitle, Common::String &caption,
107  Common::StringArray &hyperlinks);
108  void convertHyperlinks(const Common::StringArray &hyperlinks, Common::Array<LinkInfo> &links);
109 
110  void loadLinksFile();
111  void getLinks(const Common::String &record, Common::Array<LinkInfo> &links);
112 
113  Common::Path _allDocsFilePath;
114  Common::Path _linksDocsFilePath;
115 
116  static const uint kPopupMenuMargin = 5;
117 
119  FontManager *_fontManager;
120  const Sprites *_sprites;
121  const Common::StringArray *_messages;
122 
123  bool _multilineAttributes;
124 
125  Common::StringArray _recordsOrdered;
127  char *_linksData;
128  uint _linksSize;
129 
130  Common::Array<LinkInfo> _allLinks;
131 
132  Common::StringArray _visitTrace;
133  Common::String _currentRecord;
134  Common::String _categoryStartRecord;
135  Common::String _categoryEndRecord;
136  Common::String _categoryTitle;
137  Common::Array<LinkInfo> _currentLinks;
138  bool _currentInTimeline;
139  bool _currentMapLayout;
140  bool _currentHasMap;
141 };
142 
143 } // End of namespace Versailles
144 } // End of namespace CryOmni3D
145 
146 #endif
Definition: managed_surface.h:51
Definition: cryomni3d.h:62
Definition: str.h:59
Definition: font_manager.h:40
Definition: path.h:52
Definition: rect.h:45
Definition: sprites.h:40
Definition: mouse_boxes.h:37