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 49 of file C4Texture.cpp.

50  : iMaterialIndex(MNone), pMaterial(nullptr)
51 {
52 }
const int32_t MNone
Definition: C4Constants.h:178

Member Function Documentation

void C4TexMapEntry::Clear ( )

Definition at line 54 of file C4Texture.cpp.

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

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

55 {
56  Material.Clear(); Texture.Clear();
57  iMaterialIndex = MNone;
58  pMaterial = nullptr;
59  MatPattern.Clear();
60 }
void Clear()
Definition: StdBuf.h:474
const int32_t MNone
Definition: C4Constants.h:178
void Clear()
Definition: C4Draw.cpp:149

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 62 of file C4Texture.cpp.

References Clear().

Referenced by C4TextureMap::AddEntry().

63 {
64  // Clear previous data
65  Clear();
66  // Save names
67  Material = szMaterial; Texture = szTexture;
68  return true;
69 }
void Clear()
Definition: C4Texture.cpp:54

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:450

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:450

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4TexMapEntry::Init ( )

Definition at line 71 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.

72 {
73  // Find material
74  iMaterialIndex = ::MaterialMap.Get(Material.getData());
75  if (!MatValid(iMaterialIndex))
76  {
77  DebugLogF("Error initializing material %s-%s: Invalid material!", Material.getData(), Texture.getData());
78  return false;
79  }
80  pMaterial = &::MaterialMap.Map[iMaterialIndex];
81  // Find texture
82  StdStrBuf FirstTexture;
83  FirstTexture.CopyUntil(Texture.getData(), '-');
84  C4Texture * sfcTexture = ::TextureMap.GetTexture(FirstTexture.getData());
85  if (!sfcTexture)
86  {
87  DebugLogF("Error initializing material %s-%s: Invalid texture!", Material.getData(), FirstTexture.getData());
88  Clear();
89  return false;
90  }
91  // Get overlay properties
92  int32_t iOverlayType=pMaterial->OverlayType;
93  int32_t iZoom=0;
94  if (iOverlayType & C4MatOv_Exact) iZoom=1;
95  if (iOverlayType & C4MatOv_HugeZoom) iZoom=4;
96  // Create pattern
97  MatPattern.Set(sfcTexture->Surface32, iZoom);
98  return true;
99 }
const char * getData() const
Definition: StdBuf.h:450
C4Material * Map
Definition: C4Material.h:171
int32_t OverlayType
Definition: C4Material.h:117
C4Surface * Surface32
Definition: C4Texture.h:35
C4TextureMap TextureMap
Definition: C4Texture.cpp:580
#define C4MatOv_Exact
Definition: C4Material.h:32
bool DebugLogF(const char *strMessage...)
Definition: C4Log.cpp:281
#define C4MatOv_HugeZoom
Definition: C4Material.h:34
void CopyUntil(const char *szString, char cUntil)
Definition: StdBuf.h:621
int32_t Get(const char *szMaterial)
Definition: C4Material.cpp:362
const char * GetTexture(int32_t iIndex)
Definition: C4Texture.cpp:503
C4MaterialMap MaterialMap
Definition: C4Material.cpp:970
bool Set(class C4Surface *sfcSource, int iZoom=0)
Definition: C4Draw.cpp:117
bool MatValid(int32_t mat)
Definition: C4Material.h:212
void Clear()
Definition: C4Texture.cpp:54

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:449

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: