Debian Codegraph @

plugins/dm.editing/DarkmodTxt.h

raw
1 #pragma once
2
3 #include <vector>
4 #include "MissionInfoTextFile.h"
5
6 namespace map
7 {
8
9 class DarkmodTxt;
10 typedef std::shared_ptr<DarkmodTxt> DarkmodTxtPtr;
11
12 /**
13 * An object representing the darkmod.txt file as found in the
14 * mission folder's root directory. It contains information shown
15 * in the "New Mission" section in TDM's main menu.
16 */
17 class DarkmodTxt :
18 public MissionInfoTextFile
19 {
20 public:
21 typedef std::vector<std::string> TitleList;
22
23 private:
24 std::string _title;
25 std::string _author;
26 std::string _description;
27 std::string _version;
28 std::string _reqTdmVersion;
29
30 TitleList _missionTitles;
31
32 public:
33 static const char* NAME()
34 {
35 return "darkmod.txt";
36 }
37
38 std::string getFilename() override;
39
40 const std::string& getTitle();
41 void setTitle(const std::string& title);
42
43 const std::string& getAuthor();
44 void setAuthor(const std::string& author);
45
46 const std::string& getDescription();
47 void setDescription(const std::string& desc);
48
49 const std::string& getVersion();
50 void setVersion(const std::string& version);
51
52 const std::string& getReqTdmVersion();
53 void setReqTdmVersion(const std::string& reqVersion);
54
55 // Returns the mission titles (the first element is the same as getTitle())
56 const TitleList& getMissionTitles();
57 void setMissionTitles(const TitleList& list);
58
59 // Named constructor parsing the given string into a DarkmodTxt instance
60 // A parse exception will be thrown if the file is not compliant
61 static DarkmodTxtPtr CreateFromString(const std::string& contents);
62
63 // Named constructor parsing the given stream into a DarkmodTxt instance
64 // A parse exception will be thrown if the file is not compliant
65 static DarkmodTxtPtr CreateFromStream(std::istream& stream);
66
67 // A parse exception will be thrown if the file is not compliant
68 static DarkmodTxtPtr LoadForCurrentMod();
69
70 // Retrieves the text representation of this instance, as it will be written to the darkmod.txt file
71 std::string toString() override;
72
73 private:
74 static void ParseMissionTitles(std::vector<std::string>& titleList, const std::string& source);
75 };
76
77 }