HoverRace  2.0
SpriteTextureRes.h
Go to the documentation of this file.
1 
2 // SpriteTextureRes.h
3 //
4 // Copyright (c) 2014 Michael Imamura.
5 //
6 // Licensed under GrokkSoft HoverRace SourceCode License v1.0(the "License");
7 // you may not use this file except in compliance with the License.
8 //
9 // A copy of the license should have been attached to the package from which
10 // you have taken this file. If you can not find the license you can not use
11 // this file.
12 //
13 //
14 // The author makes no representations about the suitability of
15 // this software for any purpose. It is provided "as is" "AS IS",
16 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
17 // implied.
18 //
19 // See the License for the specific language governing permissions
20 // and limitations under the License.
21 
22 #pragma once
23 
24 #include "Res.h"
25 
26 #if defined(_WIN32) && defined(HR_ENGINE_SHARED)
27 # ifdef MR_ENGINE
28 # define MR_DllDeclare __declspec( dllexport )
29 # else
30 # define MR_DllDeclare __declspec( dllimport )
31 # endif
32 #else
33 # define MR_DllDeclare
34 #endif
35 
36 namespace HoverRace {
37  namespace Display {
38  class Texture;
39  }
40  namespace Parcel {
41  class ObjStream;
42  }
43 }
44 
45 namespace HoverRace {
46 namespace Display {
47 
52 class SpriteTextureRes : public Res<Texture>
53 {
55 
56 public:
57  SpriteTextureRes(const std::string &recordName,
58  Parcel::ObjStream &archive, bool flipped = false);
59  virtual ~SpriteTextureRes() { }
60 
61 public:
62  std::string GetId() const override { return id; }
63 
64  std::unique_ptr<std::istream> Open() const override
65  {
66  throw ResLoadExn("Attempted to open internal texture.");
67  }
68 
69  bool IsGenerated() const override { return true; }
70  const ImageData *GetImageData() override { return &imageData; }
71 
72 private:
73  std::string id;
74  ImageData imageData;
75 };
76 
77 } // namespace Display
78 } // namespace HoverRace
79 
80 #undef MR_DllDeclare
A resource failed to load.
Definition: Res.h:152
const ImageData * GetImageData() override
If IsGenerated() is true, returns the image data necessary to create the texture. ...
Definition: SpriteTextureRes.h:70
Base class for loadable textures.
Definition: Res.h:94
std::unique_ptr< std::istream > Open() const override
Open the stream for reading.
Definition: SpriteTextureRes.h:64
bool IsGenerated() const override
Check if this texture is generated from memory rather than an input stream.
Definition: SpriteTextureRes.h:69
Loads a legacy 8-bit sprite as a texture.
Definition: SpriteTextureRes.h:52
Base class for parcel serializers.
Definition: ObjStream.h:58
ImageData imageData
Definition: SpriteTextureRes.h:74
virtual ~SpriteTextureRes()
Definition: SpriteTextureRes.h:59
Res< Texture > SUPER
Definition: SpriteTextureRes.h:54
Base class for loadable resources.
Definition: Res.h:83
Definition: Announcement.h:24
std::string GetId() const override
Retrieve the ID for this resource.
Definition: SpriteTextureRes.h:62
std::string id
Definition: SpriteTextureRes.h:73