OpenClonk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
C4TexMapEntry Class Reference

#include <C4Texture.h>

Public Member Functions

 C4TexMapEntry ()
 
bool isNull () const
 
const char * GetMaterialName () const
 
const char * GetTextureName () const
 
int32_t GetMaterialIndex () const
 
C4MaterialGetMaterial () const
 
const C4PatternGetPattern () const
 
void Clear ()
 
bool Create (const char *szMaterial, const char *szTexture)
 
bool Init ()
 

Friends

class C4TextureMap
 

Detailed Description

Definition at line 48 of file C4Texture.h.

Constructor & Destructor Documentation

C4TexMapEntry::C4TexMapEntry ( )

Definition at line 41 of file C4Texture.cpp.

42  : iMaterialIndex(MNone)
43 {
44 }
const int32_t MNone
Definition: C4Constants.h:177

Member Function Documentation

void C4TexMapEntry::Clear ( )

Definition at line 46 of file C4Texture.cpp.

References C4Pattern::Clear(), StdStrBuf::Clear(), and MNone.

Referenced by C4TextureMap::AddEntry(), Create(), Init(), C4TextureMap::Init(), C4TextureMap::MoveIndex(), and C4TextureMap::RemoveEntry().

47 {
48  Material.Clear(); Texture.Clear();
49  iMaterialIndex = MNone;
50  pMaterial = nullptr;
51  MatPattern.Clear();
52 }
void Clear()
Definition: StdBuf.h:466
const int32_t MNone
Definition: C4Constants.h:177
void Clear()
Definition: C4Draw.cpp:146

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4TexMapEntry::Create ( const char *  szMaterial,
const char *  szTexture 
)

Definition at line 54 of file C4Texture.cpp.

References Clear().

Referenced by C4TextureMap::AddEntry().

55 {
56  // Clear previous data
57  Clear();
58  // Save names
59  Material = szMaterial; Texture = szTexture;
60  return true;
61 }
void Clear()
Definition: C4Texture.cpp:46

Here is the call graph for this function:

Here is the caller graph for this function:

C4Material* C4TexMapEntry::GetMaterial ( ) const
inline

Definition at line 63 of file C4Texture.h.

Referenced by C4Landscape::P::ChunkOZoom(), and C4TextureMap::DefaultBkgMatTex().

63 { return pMaterial; }

Here is the caller graph for this function:

int32_t C4TexMapEntry::GetMaterialIndex ( ) const
inline

Definition at line 62 of file C4Texture.h.

Referenced by C4Landscape::P::DoScan(), and PixCol2Mat().

62 { return iMaterialIndex; }

Here is the caller graph for this function:

const char* C4TexMapEntry::GetMaterialName ( ) const
inline

Definition at line 60 of file C4Texture.h.

References StdStrBuf::getData().

Referenced by C4EditCursor::ApplyToolPicker(), c4_texture_handle_get_entry_material_name(), C4MaterialMap::CrossMapMaterials(), C4ToolsDlg::SetIFT(), and C4Landscape::SetTextureIndex().

60 { return Material.getData(); }
const char * getData() const
Definition: StdBuf.h:442

Here is the call graph for this function:

Here is the caller graph for this function:

const C4Pattern& C4TexMapEntry::GetPattern ( ) const
inline

Definition at line 64 of file C4Texture.h.

Referenced by C4Landscape::P::Mat2Pal(), and C4TextureMap::StoreMapPalette().

64 { return MatPattern; }

Here is the caller graph for this function:

const char* C4TexMapEntry::GetTextureName ( ) const
inline

Definition at line 61 of file C4Texture.h.

References StdStrBuf::getData().

Referenced by C4EditCursor::ApplyToolPicker(), c4_texture_handle_get_entry_texture_name(), C4Landscape::P::ChunkOZoom(), C4MaterialMap::CrossMapMaterials(), C4ToolsDlg::SetIFT(), and C4Landscape::SetTextureIndex().

61 { return Texture.getData(); }
const char * getData() const
Definition: StdBuf.h:442

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4TexMapEntry::Init ( )

Definition at line 63 of file C4Texture.cpp.

References C4MatOv_Exact, C4MatOv_HugeZoom, Clear(), StdStrBuf::CopyUntil(), DebugLogF(), C4MaterialMap::Get(), StdStrBuf::getData(), C4TextureMap::GetTexture(), C4MaterialMap::Map, MaterialMap, MatValid(), C4MaterialCore::OverlayType, C4Pattern::Set(), C4Texture::Surface32, and TextureMap.

64 {
65  // Find material
66  iMaterialIndex = ::MaterialMap.Get(Material.getData());
67  if (!MatValid(iMaterialIndex))
68  {
69  DebugLogF("Error initializing material %s-%s: Invalid material!", Material.getData(), Texture.getData());
70  return false;
71  }
72  pMaterial = &::MaterialMap.Map[iMaterialIndex];
73  // Find texture
74  StdStrBuf FirstTexture;
75  FirstTexture.CopyUntil(Texture.getData(), '-');
76  C4Texture * sfcTexture = ::TextureMap.GetTexture(FirstTexture.getData());
77  if (!sfcTexture)
78  {
79  DebugLogF("Error initializing material %s-%s: Invalid texture!", Material.getData(), FirstTexture.getData());
80  Clear();
81  return false;
82  }
83  // Get overlay properties
84  int32_t iOverlayType=pMaterial->OverlayType;
85  int32_t iZoom=0;
86  if (iOverlayType & C4MatOv_Exact) iZoom=1;
87  if (iOverlayType & C4MatOv_HugeZoom) iZoom=4;
88  // Create pattern
89  MatPattern.Set(sfcTexture->Surface32, iZoom);
90  return true;
91 }
const char * getData() const
Definition: StdBuf.h:442
C4Material * Map
Definition: C4Material.h:169
int32_t OverlayType
Definition: C4Material.h:115
C4Surface * Surface32
Definition: C4Texture.h:35
C4TextureMap TextureMap
Definition: C4Texture.cpp:576
#define C4MatOv_Exact
Definition: C4Material.h:30
bool DebugLogF(const char *strMessage...)
Definition: C4Log.cpp:288
#define C4MatOv_HugeZoom
Definition: C4Material.h:32
void CopyUntil(const char *szString, char cUntil)
Definition: StdBuf.h:613
int32_t Get(const char *szMaterial)
Definition: C4Material.cpp:361
const char * GetTexture(int32_t iIndex)
Definition: C4Texture.cpp:494
C4MaterialMap MaterialMap
Definition: C4Material.cpp:970
bool Set(class C4Surface *sfcSource, int iZoom=0)
Definition: C4Draw.cpp:114
bool MatValid(int32_t mat)
Definition: C4Material.h:210
void Clear()
Definition: C4Texture.cpp:46

Here is the call graph for this function:

bool C4TexMapEntry::isNull ( ) const
inline

Definition at line 59 of file C4Texture.h.

References StdStrBuf::isNull().

Referenced by C4EditCursor::ApplyToolPicker(), C4Landscape::P::Mat2Pal(), and C4Landscape::SetTextureIndex().

59 { return Material.isNull(); }
bool isNull() const
Definition: StdBuf.h:441

Here is the call graph for this function:

Here is the caller graph for this function:

Friends And Related Function Documentation

friend class C4TextureMap
friend

Definition at line 50 of file C4Texture.h.


The documentation for this class was generated from the following files: