xoreos  0.0.5
nfofile.cpp
Go to the documentation of this file.
1 /* xoreos - A reimplementation of BioWare's Aurora engine
2  *
3  * xoreos is the legal property of its developers, whose names
4  * can be found in the AUTHORS file distributed with this source
5  * distribution.
6  *
7  * xoreos 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 3
10  * of the License, or (at your option) any later version.
11  *
12  * xoreos 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 xoreos. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
25 #include "src/common/error.h"
26 #include "src/common/readstream.h"
27 
28 #include "src/aurora/gff3file.h"
29 #include "src/aurora/nfofile.h"
30 
31 static const uint32 kNFOID = MKTAG('N', 'F', 'O', ' ');
32 
33 namespace Aurora {
34 
35 NFOFile::NFOFile(Common::SeekableReadStream *stream) : _timePlayed(0) {
36  GFF3File gff(stream, kNFOID);
37 
38  load(gff.getTopLevel());
39 }
40 
42 }
43 
45  return _portrait0;
46 }
47 
49  return _portrait1;
50 }
51 
53  return _portrait2;
54 }
55 
57  return _timePlayed;
58 }
59 
61  return _saveName;
62 }
63 
65  return _areaName;
66 }
67 
69  return _pcName;
70 }
71 
72 void NFOFile::load(const GFF3Struct &top) {
73  _portrait0 = top.getString("PORTRAIT0");
74  _portrait1 = top.getString("PORTRAIT1");
75  _portrait2 = top.getString("PORTRAIT2");
76 
77  _timePlayed = top.getUint("TIMEPLAYED");
78 
79  _areaName = top.getString("AREANAME");
80  _saveName = top.getString("SAVEGAMENAME");
81 
82  _pcName = top.getString("PCNAME");
83 }
84 
85 } // End of namespace Aurora
Handling version V3.2/V3.3 of BioWare&#39;s GFFs (generic file format).
const Common::UString & getAreaName() const
Get the area name.
Definition: nfofile.cpp:64
const Common::UString & getPortrait2() const
Get the second companions portrait.
Definition: nfofile.cpp:52
#define MKTAG(a0, a1, a2, a3)
A wrapper macro used around four character constants, like &#39;DATA&#39;, to ensure portability.
Definition: endianness.h:140
const Common::UString & getPortrait1() const
Get the first companions portrait.
Definition: nfofile.cpp:48
uint32 _timePlayed
The time this save was actually played.
Definition: nfofile.h:58
A class holding an UTF-8 string.
Definition: ustring.h:48
void load(const GFF3Struct &top)
Definition: nfofile.cpp:72
const GFF3Struct & getTopLevel() const
Returns the top-level struct.
Definition: gff3file.cpp:91
uint64 getUint(const Common::UString &field, uint64 def=0) const
Definition: gff3file.cpp:436
uint32 getTimePlayed() const
Get the time played.
Definition: nfofile.cpp:56
NFOFile(Common::SeekableReadStream *stream)
Definition: nfofile.cpp:35
Basic exceptions to throw.
static const uint32 kNFOID
Definition: nfofile.cpp:31
A GFF (generic file format) V3.2/V3.3 file, found in all Aurora games except Sonic Chronicles: The Da...
Definition: gff3file.h:85
const Common::UString & getPortrait0() const
Get the player portrait.
Definition: nfofile.cpp:44
Basic reading stream interfaces.
Common::UString _portrait2
The portrait of the second companion.
Definition: nfofile.h:66
Common::UString _portrait0
The portrait of the pc or solo companion.
Definition: nfofile.h:64
A struct within a GFF3.
Definition: gff3file.h:164
uint32_t uint32
Definition: types.h:204
Common::UString getString(const Common::UString &field, const Common::UString &def="") const
Definition: gff3file.cpp:527
Common::UString _saveName
The save name.
Definition: nfofile.h:60
Common::UString _areaName
The current area to load.
Definition: nfofile.h:61
Loader for the savenfo.res file, storing savegame metadata for kotor 1 and 2.
const Common::UString & getSaveName() const
Get the area name.
Definition: nfofile.cpp:60
Interface for a seekable & readable data stream.
Definition: readstream.h:265
const Common::UString & getPCName() const
Get the pc name (kotor2 only).
Definition: nfofile.cpp:68
Common::UString _pcName
The name of the pc (kotor2 only).
Definition: nfofile.h:62
Common::UString _portrait1
The portrait of the first companion.
Definition: nfofile.h:65