OSDN Git Service

イニシャルコミット。
[marathon/ShapeFusion.git] / Physics / PhysicsDocument.h
1 /*
2  * This file is part of ShapeFusion (Copyright 2000 Tito Dal Canton)
3  *
4  * ShapeFusion is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * ShapeFusion is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with ShapeFusion; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17 */
18
19 #ifndef __PHYSICSDOCUMENT_H__
20 #define __PHYSICSDOCUMENT_H__
21
22 #include "wx/docview.h"
23 #include "wx/cmdproc.h"
24
25 #include <vector>
26
27 #include <stdint.h>
28
29 #include "PhysicsElements.h"
30
31 class PhysicsDocument : public wxDocument, public PhysicsElement
32 {
33         DECLARE_DYNAMIC_CLASS(PhysicsDocument)
34
35 private:
36         std::vector<MonsterDefinition> mMonsterDefinitions;
37         std::vector<EffectDefinition> mEffectDefinitions;
38         std::vector<ProjectileDefinition> mProjectileDefinitions;
39         std::vector<PhysicsConstants> mConstants;
40         std::vector<WeaponDefinition> mWeaponDefinitions;
41
42         static const int MAXIMUM_WADFILE_NAME_LENGTH = 64;
43         unsigned char wadfile_name[MAXIMUM_WADFILE_NAME_LENGTH];
44         
45         static const int kEntryHeaderSize = 16;
46
47 public:
48         // counts
49         unsigned int MonsterCount() const { return mMonsterDefinitions.size(); }
50         unsigned int EffectCount() const { return mEffectDefinitions.size(); }
51         unsigned int ProjectileCount() const { return mProjectileDefinitions.size(); }
52         unsigned int PhysicsConstantsCount() const { return mConstants.size(); }
53         unsigned int WeaponCount() const { return mWeaponDefinitions.size(); }
54
55         // element accessors
56         PhysicsConstants* GetPhysicsConstants(unsigned int id) { 
57                 return &mConstants[id];
58         }
59
60         EffectDefinition* GetEffectDefinition(unsigned int id) {
61                 return &mEffectDefinitions[id];
62         }
63
64         ProjectileDefinition* GetProjectileDefinition(unsigned int id) {
65                 return &mProjectileDefinitions[id];
66         }
67         
68         MonsterDefinition* GetMonsterDefinition(unsigned int id) {
69                 return &mMonsterDefinitions[id];
70         }
71
72         WeaponDefinition* GetWeaponDefinition(unsigned int id) {
73                 return &mWeaponDefinitions[id];
74         }
75
76         PhysicsDocument();
77         ~PhysicsDocument();
78
79         bool DoOpenDocument(const wxString& file);
80
81 #if wxUSE_STD_IOSTREAM
82         wxSTD ostream& SaveObject(wxSTD ostream& stream);
83         wxSTD istream& LoadObject(wxSTD istream& stream);
84 #else
85         wxOutputStream& SaveObject(wxOutputStream& stream);
86         wxInputStream& LoadObject(wxInputStream& stream);
87 #endif
88
89         unsigned long SizeInFile();
90         template<class T> void WriteTag(BigEndianBuffer& buffer, long& offset, unsigned long tag, const std::vector<T>& data, bool last = false);
91 };
92
93 #endif