OpenClonk
C4FacetEx.h
Go to the documentation of this file.
1 /*
2  * OpenClonk, http://www.openclonk.org
3  *
4  * Copyright (c) 1998-2000, Matthes Bender
5  * Copyright (c) 2001-2009, RedWolf Design GmbH, http://www.clonk.de/
6  * Copyright (c) 2009-2016, The OpenClonk Team and contributors
7  *
8  * Distributed under the terms of the ISC license; see accompanying file
9  * "COPYING" for details.
10  *
11  * "Clonk" is a registered trademark of Matthes Bender, used with permission.
12  * See accompanying file "TRADEMARK" for details.
13  *
14  * To redistribute this file separately, substitute the full license texts
15  * for the above references.
16  */
17 
18 /* A facet that can hold its own surface and also target coordinates */
19 
20 #ifndef INC_C4FacetEx
21 #define INC_C4FacetEx
22 
23 #include "graphics/C4Facet.h"
24 #include "graphics/C4Surface.h"
25 
26 const int C4FCT_Full = -1,
29 
30 // facet that can hold its own surface
31 class C4FacetSurface : public C4Facet
32 {
33 private:
34  C4Surface Face;
35 
36 private:
37  C4FacetSurface(const C4FacetSurface &rCpy); // NO copy!
38  C4FacetSurface &operator = (const C4FacetSurface &rCpy); // NO copy assignment!
39 public:
42 
43  void Default() { Face.Default(); C4Facet::Default(); }
44  void Clear() { Face.Clear(); }
45 
46  void Set(const C4Facet &cpy) { Clear(); C4Facet::Set(cpy); }
47  void Set(C4Surface * nsfc, int nx, int ny, int nwdt, int nhgt)
48  { C4Facet::Set(nsfc, nx,ny,nwdt,nhgt); }
49 
50  void Grayscale(int32_t iOffset = 0);
51  bool Create(int iWdt, int iHgt, int iWdt2=C4FCT_Full, int iHgt2=C4FCT_Full);
52  C4Surface &GetFace() { return Face; } // get internal face
53  bool CreateClrByOwner(C4Surface *pBySurface);
54  bool EnsureOwnSurface();
55  bool Load(C4Group &hGroup, const char *szName, int iWdt, int iHgt, bool fNoErrIfNotFound, int iFlags);
56  bool Save(C4Group &hGroup, const char *szName);
57  void GrabFrom(C4FacetSurface &rSource)
58  {
59  Clear(); Default();
60  Face.MoveFrom(&rSource.Face);
61  Set(rSource.Surface == &rSource.Face ? &Face : rSource.Surface, rSource.X, rSource.Y, rSource.Wdt, rSource.Hgt);
62  rSource.Default();
63  }
64  bool CopyFromSfcMaxSize(C4Surface &srcSfc, int32_t iMaxSize, uint32_t dwColor=0u);
65 };
66 
67 // facet with source group ID; used to avoid doubled loading from same group
68 class C4FacetID : public C4FacetSurface
69 {
70 public:
71  int32_t idSourceGroup{0};
72 
73  C4FacetID() : C4FacetSurface() { } // ctor
74 
75  void Default() { C4FacetSurface::Default(); idSourceGroup = 0; } // default to std values
76  void Clear() { C4FacetSurface::Clear(); idSourceGroup = 0; } // clear all data in class
77 };
78 
79 #endif
const int C4FCT_Full
Definition: C4FacetEx.h:26
const int C4FCT_Width
Definition: C4FacetEx.h:28
const int C4FCT_Height
Definition: C4FacetEx.h:27
void Set(C4Surface &rSfc)
Definition: C4Facet.cpp:459
C4Surface * Surface
Definition: C4Facet.h:117
float Hgt
Definition: C4Facet.h:118
float Wdt
Definition: C4Facet.h:118
void Default()
Definition: C4Facet.cpp:31
float Y
Definition: C4Facet.h:118
float X
Definition: C4Facet.h:118
void Clear()
Definition: C4FacetEx.h:76
int32_t idSourceGroup
Definition: C4FacetEx.h:71
void Default()
Definition: C4FacetEx.h:75
C4FacetID()
Definition: C4FacetEx.h:73
bool Load(C4Group &hGroup, const char *szName, int iWdt, int iHgt, bool fNoErrIfNotFound, int iFlags)
Definition: C4FacetEx.cpp:84
bool Create(int iWdt, int iHgt, int iWdt2=C4FCT_Full, int iHgt2=C4FCT_Full)
Definition: C4FacetEx.cpp:54
void Clear()
Definition: C4FacetEx.h:44
void GrabFrom(C4FacetSurface &rSource)
Definition: C4FacetEx.h:57
void Set(C4Surface *nsfc, int nx, int ny, int nwdt, int nhgt)
Definition: C4FacetEx.h:47
bool CreateClrByOwner(C4Surface *pBySurface)
Definition: C4FacetEx.cpp:73
void Set(const C4Facet &cpy)
Definition: C4FacetEx.h:46
bool CopyFromSfcMaxSize(C4Surface &srcSfc, int32_t iMaxSize, uint32_t dwColor=0u)
Definition: C4FacetEx.cpp:117
C4Surface & GetFace()
Definition: C4FacetEx.h:52
bool Save(C4Group &hGroup, const char *szName)
bool EnsureOwnSurface()
Definition: C4FacetEx.cpp:168
void Default()
Definition: C4FacetEx.h:43
void Grayscale(int32_t iOffset=0)
Definition: C4FacetEx.cpp:162
void Clear()
Definition: C4Surface.cpp:126
void MoveFrom(C4Surface *psfcFrom)
Definition: C4Surface.cpp:94
void Default()
Definition: C4Surface.cpp:71