OpenClonk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
C4Texture.cpp
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 /* Textures used by the landscape */
19 
20 #include "C4Include.h"
21 #include "landscape/C4Texture.h"
23 
24 #include "c4group/C4Group.h"
25 #include "game/C4Game.h"
26 #include "config/C4Config.h"
27 #include "c4group/C4Components.h"
28 #include "landscape/C4Material.h"
29 #include "landscape/C4Landscape.h"
30 #include "lib/C4Log.h"
31 #include "lib/C4Random.h"
32 #include "lib/StdColors.h"
33 
34 #include <ctype.h>
35 #include <algorithm>
36 
38 {
39  Surface32=nullptr;
40  AvgColor = 0x00000000;
41  Next=nullptr;
42 }
43 
45 {
46  delete Surface32;
47 }
48 
50  : iMaterialIndex(MNone), pMaterial(nullptr)
51 {
52 }
53 
55 {
56  Material.Clear(); Texture.Clear();
57  iMaterialIndex = MNone;
58  pMaterial = nullptr;
59  MatPattern.Clear();
60 }
61 
62 bool C4TexMapEntry::Create(const char *szMaterial, const char *szTexture)
63 {
64  // Clear previous data
65  Clear();
66  // Save names
67  Material = szMaterial; Texture = szTexture;
68  return true;
69 }
70 
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 }
100 
101 C4TextureMap::C4TextureMap() : FirstTexture(nullptr), fEntriesAdded(false), fOverloadMaterials(false), fOverloadTextures(false), fInitialized(false)
102 {
103  Order.reserve(C4M_MaxTexIndex);
104 }
105 
107 {
108  Clear();
109 }
110 
111 bool C4TextureMap::AddEntry(BYTE byIndex, const char *szMaterial, const char *szTexture)
112 {
113  // Security
114  if (byIndex <= 0 || byIndex >= C4M_MaxTexIndex)
115  return false;
116  // Set entry and initialize
117  Entry[byIndex].Create(szMaterial, szTexture);
118  if (fInitialized)
119  {
120  if (!Entry[byIndex].Init())
121  {
122  // Clear entry if it could not be initialized
123  Entry[byIndex].Clear();
124  return false;
125  }
126  // Landscape must be notified (new valid pixel clr)
128  }
129  // Add last in order list
130  Order.push_back(byIndex);
131  return true;
132 }
133 
134 bool C4TextureMap::AddTexture(const char *szTexture, C4Surface * sfcSurface)
135 {
136  C4Texture *pTexture;
137  if (!(pTexture=new C4Texture)) return false;
138  pTexture->Name.Copy(szTexture);
139  pTexture->Surface32=sfcSurface;
140  pTexture->Next=FirstTexture;
141  FirstTexture=pTexture;
142 
143  // Compute average texture color
144  if(sfcSurface)
145  {
146  sfcSurface->Lock();
147  uint32_t avg_c[4] = { 0, 0, 0, 0 };
148  for(int32_t y = 0; y < sfcSurface->Hgt; ++y)
149  {
150  for(int32_t x = 0; x < sfcSurface->Wdt; ++x)
151  {
152  DWORD c = sfcSurface->GetPixDw(x, y, false);
153  avg_c[0] += c & 0xff;
154  avg_c[1] += (c >> 8) & 0xff;
155  avg_c[2] += (c >> 16) & 0xff;
156  avg_c[3] += (c >> 24) & 0xff;
157  }
158  }
159  sfcSurface->Unlock();
160 
161  double Size = sfcSurface->Wdt * sfcSurface->Hgt;
162  avg_c[0] = static_cast<uint32_t>(avg_c[0] / Size + 0.5);
163  avg_c[1] = static_cast<uint32_t>(avg_c[1] / Size + 0.5);
164  avg_c[2] = static_cast<uint32_t>(avg_c[2] / Size + 0.5);
165  avg_c[3] = static_cast<uint32_t>(avg_c[3] / Size + 0.5);
166  pTexture->SetAverageColor(avg_c[0] | (avg_c[1] << 8) | (avg_c[2] << 16) | (avg_c[3] << 24));
167  }
168  else
169  {
170  pTexture->SetAverageColor(0x00000000);
171  }
172 
173  return true;
174 }
175 
177 {
178  for (int32_t i = 1; i < C4M_MaxTexIndex; i++)
179  Entry[i].Clear();
180  C4Texture *ctex,*next2;
181  for (ctex=FirstTexture; ctex; ctex=next2)
182  {
183  next2=ctex->Next;
184  delete ctex;
185  }
186  FirstTexture=nullptr;
187  fInitialized = false;
188  fEntriesAdded = false;
189  fOverloadMaterials = false;
190  fOverloadTextures = false;
191  Order.clear();
192  Order.reserve(C4M_MaxTexIndex);
193 }
194 
195 bool C4TextureMap::LoadFlags(C4Group &hGroup, const char *szEntryName, bool *pOverloadMaterials, bool *pOverloadTextures)
196 {
197  // Load the file
198  StdStrBuf TexMap;
199  if (!hGroup.LoadEntryString(szEntryName, &TexMap))
200  return false;
201  // Reset flags
202  if (pOverloadMaterials) *pOverloadMaterials = false;
203  if (pOverloadTextures) *pOverloadTextures = false;
204  // Check if there are flags in there
205  for (const char *pPos = TexMap.getData(); pPos && *pPos; pPos = SSearch(pPos + 1, "\n"))
206  {
207  // Go over newlines
208  while (*pPos == '\r' || *pPos == '\n') pPos++;
209  // Flag?
210  if (pOverloadMaterials && SEqual2(pPos, "OverloadMaterials"))
211  *pOverloadMaterials = true;
212  if (pOverloadTextures && SEqual2(pPos, "OverloadTextures"))
213  *pOverloadTextures = true;
214  }
215  // Done
216  return true;
217 }
218 
219 int32_t C4TextureMap::LoadMap(C4Group &hGroup, const char *szEntryName, bool *pOverloadMaterials, bool *pOverloadTextures)
220 {
221  static std::regex line_terminator("\r?\n", static_cast<std::regex::flag_type>(std::regex_constants::optimize | std::regex_constants::ECMAScript));
222 
223  char *bpMap;
224  size_t map_size;
225  int32_t iTextures = 0;
226  // Load text file into memory
227  if (!hGroup.LoadEntry(szEntryName,&bpMap,&map_size,1)) return 0;
228 
229  char *begin = bpMap;
230  char *end = begin + map_size;
231 
232  size_t line = 1; // Counter for error messages
233  for (auto it = std::cregex_token_iterator(begin, end, line_terminator, -1); it != std::cregex_token_iterator(); ++it, ++line)
234  {
235  if (it->compare("OverloadMaterials") == 0)
236  {
237  fOverloadMaterials = true;
238  if (pOverloadMaterials)
239  *pOverloadMaterials = true;
240  }
241  else if (it->compare("OverloadTextures") == 0)
242  {
243  fOverloadTextures = true;
244  if (pOverloadTextures)
245  *pOverloadTextures = true;
246  }
247  else if (it->length() == 0 || it->first[0] == '#' || std::all_of(it->first, it->second, &isspace))
248  {
249  // Skip empty lines, comments, and all-whitespace lines
250  continue;
251  }
252  else
253  {
254  // This must be a texmap entry now
255  std::string value;
256 
257  // Read index
258  unsigned long index;
259  try
260  {
261  size_t separator;
262  index = std::stoul(it->str(), &separator, 10);
263  if (index >= C4M_MaxTexIndex)
264  throw std::out_of_range("Texture index out of range");
265  value.assign(it->first + separator + 1, it->second);
266  }
267  catch (std::invalid_argument &)
268  {
269  DebugLogF("TexMap line %u: Texture index is not numeric", static_cast<unsigned>(line));
270  continue;
271  }
272  catch (std::out_of_range &)
273  {
274  DebugLogF("TexMap line %u: Texture index is out of range", static_cast<unsigned>(line));
275  continue;
276  }
277 
278  // Split material/texture combination
279  std::string::const_iterator separator = std::find(value.cbegin(), value.cend(), '-');
280  if (separator == value.cend())
281  {
282  DebugLogF("TexMap line %u: Texture name \"%s\" is invalid (missing \"-\")", static_cast<unsigned>(line), value.c_str());
283  continue;
284  }
285 
286  std::string material(value.cbegin(), separator);
287  std::string texture(separator + 1, value.cend());
288 
289  if (AddEntry(index, material.c_str(), texture.c_str()))
290  ++iTextures;
291  }
292  }
293 
294  // Delete buffer, return entry count
295  delete [] bpMap;
296  fEntriesAdded=false;
297  return iTextures;
298 }
299 
301 {
302  int32_t iRemoved = 0;
303  // Initialize texture mappings
304  int32_t i;
305  for (i = 0; i < C4M_MaxTexIndex; i++)
306  if (!Entry[i].isNull())
307  if (!Entry[i].Init())
308  {
309  LogF("Error in TextureMap initialization at entry %d", (int) i);
310  Entry[i].Clear();
311  iRemoved++;
312  }
313  fInitialized = true;
314  return iRemoved;
315 }
316 
317 bool C4TextureMap::SaveMap(C4Group &hGroup, const char *szEntryName)
318 {
319  // build file in memory
320  StdStrBuf sTexMapFile;
321  // add desc
322  sTexMapFile.Append("# Automatically generated texture map" LineFeed);
323  sTexMapFile.Append("# Contains material-texture-combinations added at runtime" LineFeed);
324  // add overload-entries
325  if (fOverloadMaterials) sTexMapFile.Append("# Import materials from global file as well" LineFeed "OverloadMaterials" LineFeed);
326  if (fOverloadTextures) sTexMapFile.Append("# Import textures from global file as well" LineFeed "OverloadTextures" LineFeed);
327  sTexMapFile.Append(LineFeed);
328  // add entries
329  for (auto iter = Order.begin(); iter != Order.end(); ++iter)
330  {
331  int32_t i = *iter;
332  if (!Entry[i].isNull())
333  {
334  // compose line
335  sTexMapFile.AppendFormat("%d=%s-%s" LineFeed, i, Entry[i].GetMaterialName(), Entry[i].GetTextureName());
336  }
337  }
338  // create new buffer allocated with new [], because C4Group cannot handle StdStrBuf-buffers
339  size_t iBufSize = sTexMapFile.getLength();
340  BYTE *pBuf = new BYTE[iBufSize];
341  memcpy(pBuf, sTexMapFile.getData(), iBufSize);
342  // add to group
343  bool fSuccess = !!hGroup.Add(szEntryName, pBuf, iBufSize, false, true);
344  if (!fSuccess) delete [] pBuf;
345  // done
346  return fSuccess;
347 }
348 
349 int32_t C4TextureMap::LoadTextures(C4Group &hGroup, C4Group* OverloadFile)
350 {
351  int32_t texnum=0;
352  // overload: load from other file
353  if (OverloadFile) texnum+=LoadTextures(*OverloadFile);
354 
355  char texname[256+1];
356  C4Surface *ctex;
357  size_t binlen;
358 
359  hGroup.ResetSearch();
360  while (hGroup.AccessNextEntry("*",&binlen,texname))
361  {
362  // check if it already exists in the map
363  const char *base_filename = GetFilenameOnly(texname);
364  if (GetTexture(base_filename)) continue;
365  // skip shape textures for now. Will be added later after all base textures have been loaded
366  if (WildcardMatch("*" C4CFN_MaterialShapeFiles, texname)) continue;
367  // create surface
368  ctex = new C4Surface();
369  if (ctex->Read(hGroup, GetExtension(texname), C4SF_MipMap))
370  {
371  SReplaceChar(texname,'.',0);
372  if (AddTexture(texname,ctex)) texnum++;
373  else delete ctex;
374  }
375  else
376  {
377  delete ctex;
378  }
379  }
380 
381  // Load texture shapes
382  hGroup.ResetSearch();
383  while (hGroup.AccessNextEntry("*" C4CFN_MaterialShapeFiles, &binlen, texname))
384  {
385  // get associated texture
386  StdStrBuf texname4shape(texname, true);
387  texname4shape.SetLength(texname4shape.getLength() - SLen(C4CFN_MaterialShapeFiles));
388  C4Texture *base_tex = GetTexture(texname4shape.getData());
389  if (!base_tex || !base_tex->Surface32)
390  {
391  LogF("ERROR: Texture shape %s not loaded because associated texture (%s) not found or invalid.", hGroup.GetFullName().getData(), texname4shape.getData());
392  continue;
393  }
394  std::unique_ptr<C4TextureShape> shape(new C4TextureShape());
395  int32_t scaler_zoom = 4;
396  if (!shape->Load(hGroup, texname, base_tex->Surface32->Wdt / scaler_zoom, base_tex->Surface32->Hgt / scaler_zoom))
397  {
398  LogF("Error loading texture shape %s.", hGroup.GetFullName().getData());
399  continue;
400  }
401  base_tex->SetMaterialShape(shape.release());
402  }
403 
404  return texnum;
405 }
406 
408 {
409  return hGroup.EntryCount(C4CFN_PNGFiles) || hGroup.EntryCount(C4CFN_BitmapFiles);
410 }
411 
412 void C4TextureMap::MoveIndex(BYTE byOldIndex, BYTE byNewIndex)
413 {
414  if (byNewIndex == byOldIndex) return;
415  Entry[byNewIndex] = Entry[byOldIndex];
416  Entry[byOldIndex].Clear();
417  auto old_entry = std::find_if(Order.begin(), Order.end(),
418  [byOldIndex](const int32_t &entry) { return entry == byOldIndex; });
419  if (old_entry != Order.end()) *old_entry = byNewIndex;
420  fEntriesAdded = true;
421 }
422 
423 int32_t C4TextureMap::GetIndex(const char *szMaterial, const char *szTexture, bool fAddIfNotExist, const char *szErrorIfFailed)
424 {
425  BYTE byIndex;
426  // Find existing
427  for (byIndex = 1; byIndex < C4M_MaxTexIndex; byIndex++)
428  if (!Entry[byIndex].isNull())
429  if (SEqualNoCase(Entry[byIndex].GetMaterialName(), szMaterial))
430  if (!szTexture || SEqualNoCase(Entry[byIndex].GetTextureName(), szTexture))
431  return byIndex;
432  // Add new entry
433  if (fAddIfNotExist)
434  for (byIndex=1; byIndex<C4M_MaxTexIndex; byIndex++)
435  if (Entry[byIndex].isNull())
436  {
437  if (AddEntry(byIndex, szMaterial, szTexture))
438  {
439  fEntriesAdded=true;
440  return byIndex;
441  }
442  if (szErrorIfFailed) DebugLogF("Error getting MatTex %s-%s for %s from TextureMap: Init failed.", szMaterial, szTexture, szErrorIfFailed);
443  return 0;
444  }
445  // Else, fail
446  if (szErrorIfFailed) DebugLogF("Error getting MatTex %s-%s for %s from TextureMap: %s.", szMaterial, szTexture, szErrorIfFailed, fAddIfNotExist ? "Map is full!" : "Entry not found.");
447  return 0;
448 }
449 
450 int32_t C4TextureMap::GetIndexMatTex(const char *szMaterialTexture, const char *szDefaultTexture, bool fAddIfNotExist, const char *szErrorIfFailed)
451 {
452  // split material/texture pair
453  StdStrBuf Material, Texture;
454  Material.CopyUntil(szMaterialTexture, '-');
455  Texture.Copy(SSearch(szMaterialTexture, "-"));
456  // texture not given or invalid?
457  int32_t iMatTex = 0;
458  if (Texture.getData())
459  if ((iMatTex = GetIndex(Material.getData(), Texture.getData(), fAddIfNotExist)))
460  return iMatTex;
461  if (szDefaultTexture)
462  if ((iMatTex = GetIndex(Material.getData(), szDefaultTexture, fAddIfNotExist)))
463  return iMatTex;
464  // search material
465  long iMaterial = ::MaterialMap.Get(szMaterialTexture);
466  if (!MatValid(iMaterial))
467  {
468  if (szErrorIfFailed) DebugLogF("Error getting MatTex for %s: Invalid material", szErrorIfFailed);
469  return 0;
470  }
471  // return default map entry
473 }
474 
475 C4Texture * C4TextureMap::GetTexture(const char *szTexture)
476 {
477  C4Texture *pTexture;
478  for (pTexture=FirstTexture; pTexture; pTexture=pTexture->Next)
479  if (SEqualNoCase(pTexture->Name.getData(),szTexture))
480  return pTexture;
481  return nullptr;
482 }
483 
484 int32_t C4TextureMap::GetTextureIndex(const char *szName)
485 {
486  C4Texture *pTexture;
487  int32_t i=0;
488  for (pTexture=FirstTexture; pTexture; pTexture=pTexture->Next, i++)
489  if (SEqualNoCase(pTexture->Name.getData(),szName))
490  return i;
491  return -1;
492 }
493 
494 bool C4TextureMap::CheckTexture(const char *szTexture)
495 {
496  C4Texture *pTexture;
497  for (pTexture=FirstTexture; pTexture; pTexture=pTexture->Next)
498  if (SEqualNoCase(pTexture->Name.getData(),szTexture))
499  return true;
500  return false;
501 }
502 
503 const char* C4TextureMap::GetTexture(int32_t iIndex)
504 {
505  C4Texture *pTexture;
506  int32_t cindex;
507  for (pTexture=FirstTexture,cindex=0; pTexture; pTexture=pTexture->Next,cindex++)
508  if (cindex==iIndex)
509  return pTexture->Name.getData();
510  return nullptr;
511 }
512 
514 {
515  // For the given foreground index, find the default background index
516  // If fg is semisolid, this is tunnel.
517  // Otherwise it is fg itself, so that tunnel and background bricks
518  // stay the way they are.
519  int32_t iTex = PixCol2Tex(fg);
520  if (!iTex) return fg; // sky
521 
522  // Get material-texture mapping
523  const C4TexMapEntry *pTex = GetEntry(iTex);
524  // Texmap entry does not exist
525  if(!pTex || !pTex->GetMaterial()) return fg;
526 
527  if(DensitySemiSolid(pTex->GetMaterial()->Density))
528  return Mat2PixColDefault(MTunnel);
529 
530  return fg;
531 
532 }
533 
534 void C4TextureMap::RemoveEntry(int32_t iIndex)
535 {
536  // remove entry from table and order vector
537  if (Inside<int32_t>(iIndex, 1, C4M_MaxTexIndex - 1))
538  {
539  Entry[iIndex].Clear();
540  auto last_entry = std::remove_if(Order.begin(), Order.end(),
541  [iIndex](const int32_t &entry) { return entry == iIndex; });
542  Order.erase(last_entry, Order.end());
543  }
544 }
545 
547 {
548  // Sky color
549  Palette->Colors[0] = C4RGB(192, 196, 252);
550  // Material colors by texture map entries
551  bool fSet[C4M_MaxTexIndex];
552  ZeroMem(&fSet, sizeof (fSet));
553  int32_t i;
554  for (i = 0; i < C4M_MaxTexIndex; i++)
555  {
556  // Find material
557  DWORD dwPix = Entry[i].GetPattern().PatternClr(0, 0);
558  Palette->Colors[i] = dwPix;
559  fSet[i] = true;
560  }
561  // Crosscheck colors, change equal palette entries
562  for (i = 0; i < C4M_MaxTexIndex; i++) if (fSet[i])
563  for (;;)
564  {
565  // search equal entry
566  int32_t j = 0;
567  for (; j < i; j++)
568  if (fSet[j] && Palette->Colors[i] == Palette->Colors[j])
569  break;
570  // not found? ok then
571  if (j >= i) break;
572  // change randomly
573  Palette->Colors[i] = C4RGB(
574  UnsyncedRandom(2) ? GetRedValue(Palette->Colors[i]) + 3 : GetRedValue(Palette->Colors[i]) - 3,
575  UnsyncedRandom(2) ? GetGreenValue(Palette->Colors[i]) + 3 : GetGreenValue(Palette->Colors[i]) - 3,
576  UnsyncedRandom(2) ? GetBlueValue(Palette->Colors[i]) + 3 : GetBlueValue(Palette->Colors[i]) - 3);
577  }
578 }
579 
const char * getData() const
Definition: StdBuf.h:450
uint32_t AvgColor
Definition: C4Texture.h:43
int32_t DefaultMatTex
Definition: C4Material.h:157
DWORD PatternClr(unsigned int iX, unsigned int iY) const
Definition: C4Draw.cpp:162
int EntryCount(const char *szWildCard=nullptr)
Definition: C4Group.cpp:1850
int Wdt
Definition: C4Surface.h:67
C4Material * GetMaterial() const
Definition: C4Texture.h:63
#define GetGreenValue(rgb)
Definition: StdColors.h:30
uint32_t UnsyncedRandom()
Definition: C4Random.cpp:58
void Clear()
Definition: StdBuf.h:474
void HandleTexMapUpdate()
BYTE DefaultBkgMatTex(BYTE fg) const
Definition: C4Texture.cpp:513
bool AddEntry(BYTE byIndex, const char *szMaterial, const char *szTexture)
Definition: C4Texture.cpp:111
bool Lock()
Definition: C4Surface.cpp:463
void Clear()
Definition: C4Texture.cpp:176
int32_t GetTextureIndex(const char *pTexName)
Definition: C4Texture.cpp:484
const char * SSearch(const char *szString, const char *szIndex)
Definition: Standard.cpp:333
bool AccessNextEntry(const char *szWildCard, size_t *iSize=nullptr, char *sFileName=nullptr, bool fStartAtFilename=false)
Definition: C4Group.cpp:1719
C4Material * Map
Definition: C4Material.h:171
bool Create(const char *szMaterial, const char *szTexture)
Definition: C4Texture.cpp:62
bool SEqualNoCase(const char *szStr1, const char *szStr2, int iLen)
Definition: Standard.cpp:177
bool Unlock()
Definition: C4Surface.cpp:474
DWORD Colors[256]
Definition: StdColors.h:186
int32_t OverlayType
Definition: C4Material.h:117
C4Surface * Surface32
Definition: C4Texture.h:35
bool LoadEntry(const char *szEntryName, char **lpbpBuf, size_t *ipSize=nullptr, int iAppendZeros=0)
Definition: C4Group.cpp:1893
uint8_t BYTE
static bool LoadFlags(C4Group &hGroup, const char *szEntryName, bool *pOverloadMaterials, bool *pOverloadTextures)
Definition: C4Texture.cpp:195
int32_t LoadMap(C4Group &hGroup, const char *szEntryName, bool *pOverloadMaterials, bool *pOverloadTextures)
Definition: C4Texture.cpp:219
C4TextureMap TextureMap
Definition: C4Texture.cpp:580
#define GetRedValue(rgb)
Definition: StdColors.h:31
bool DensitySemiSolid(int32_t dens)
Definition: C4Landscape.h:204
const char * GetFilenameOnly(const char *strFilename)
Definition: StdFile.cpp:70
size_t SLen(const char *sptr)
Definition: Standard.h:78
const C4TexMapEntry * GetEntry(int32_t iIndex) const
Definition: C4Texture.h:85
Definition: C4Texture.h:48
int Hgt
Definition: C4Surface.h:67
int32_t MTunnel
Definition: C4Material.cpp:37
bool SaveMap(C4Group &hGroup, const char *szEntryName)
Definition: C4Texture.cpp:317
int32_t GetIndex(const char *szMaterial, const char *szTexture, bool fAddIfNotExist=true, const char *szErrorIfFailed=nullptr)
Definition: C4Texture.cpp:423
void AppendFormat(const char *szFmt,...) GNUC_FORMAT_ATTRIBUTE_O
Definition: StdBuf.cpp:197
#define C4CFN_BitmapFiles
Definition: C4Components.h:173
void SetMaterialShape(class C4TextureShape *s)
Definition: C4Texture.h:39
#define C4MatOv_Exact
Definition: C4Material.h:32
void SetAverageColor(uint32_t Color)
Definition: C4Texture.h:37
const C4Pattern & GetPattern() const
Definition: C4Texture.h:64
#define C4CFN_MaterialShapeFiles
Definition: C4Components.h:133
void RemoveEntry(int32_t iIndex)
Definition: C4Texture.cpp:534
bool CheckTexture(const char *szTexture)
Definition: C4Texture.cpp:494
const int32_t MNone
Definition: C4Constants.h:178
bool DebugLogF(const char *strMessage...)
Definition: C4Log.cpp:281
void Clear()
Definition: C4Draw.cpp:149
#define GetBlueValue(rgb)
Definition: StdColors.h:29
StdStrBuf GetFullName() const
Definition: C4Group.cpp:2078
C4Landscape Landscape
bool AddTexture(const char *szTexture, C4Surface *sfcSurface)
Definition: C4Texture.cpp:134
const int C4M_MaxTexIndex
Definition: C4Constants.h:51
C4TexMapEntry Entry[C4M_MaxTexIndex]
Definition: C4Texture.h:76
void MoveIndex(BYTE byOldIndex, BYTE byNewIndex)
Definition: C4Texture.cpp:412
void Append(const char *pnData, size_t iChars)
Definition: StdBuf.h:527
bool fOverloadMaterials
Definition: C4Texture.h:79
const int C4SF_MipMap
Definition: C4Surface.h:52
std::vector< int32_t > Order
Definition: C4Texture.h:77
#define C4RGB(r, g, b)
Definition: StdColors.h:28
char * GetExtension(char *szFilename)
Definition: StdFile.cpp:131
#define C4CFN_PNGFiles
Definition: C4Components.h:172
#define C4MatOv_HugeZoom
Definition: C4Material.h:34
DWORD GetPixDw(int iX, int iY, bool fApplyModulation)
Definition: C4Surface.cpp:501
void CopyUntil(const char *szString, char cUntil)
Definition: StdBuf.h:621
#define LineFeed
Definition: Standard.h:151
int32_t Density
Definition: C4Material.h:94
void StoreMapPalette(CStdPalette *, C4MaterialMap &rMaterials)
Definition: C4Texture.cpp:546
int32_t Get(const char *szMaterial)
Definition: C4Material.cpp:362
const char * GetTexture(int32_t iIndex)
Definition: C4Texture.cpp:503
bool LoadEntryString(const char *szEntryName, StdStrBuf *Buf)
Definition: C4Group.cpp:1932
int32_t LoadTextures(C4Group &hGroup, C4Group *OverloadFile=0)
Definition: C4Texture.cpp:349
StdStrBuf Name
Definition: C4Texture.h:42
int32_t Init()
Definition: C4Texture.cpp:300
C4Texture * Next
Definition: C4Texture.h:45
bool Read(CStdStream &hGroup, const char *extension, int iFlags)
bool fInitialized
Definition: C4Texture.h:81
bool WildcardMatch(const char *szWildcard, const char *szString)
Definition: StdFile.cpp:384
C4MaterialMap MaterialMap
Definition: C4Material.cpp:970
bool SEqual2(const char *szStr1, const char *szStr2)
Definition: Standard.cpp:168
BYTE Mat2PixColDefault(int32_t mat)
Definition: C4Material.h:237
bool Add(const char *szFile, const char *szAddAs)
Definition: C4Group.cpp:1316
bool Set(class C4Surface *sfcSource, int iZoom=0)
Definition: C4Draw.cpp:117
size_t getLength() const
Definition: StdBuf.h:453
void ResetSearch(bool reload_contents=false)
Definition: C4Group.cpp:1013
void SetLength(size_t iLength)
Definition: StdBuf.h:517
bool fOverloadTextures
Definition: C4Texture.h:80
std::enable_if< std::is_pod< T >::value >::type ZeroMem(T *lpMem, size_t dwSize)
Definition: Standard.h:63
bool Init()
Definition: C4Texture.cpp:71
C4Texture * FirstTexture
Definition: C4Texture.h:78
uint32_t DWORD
int32_t GetIndexMatTex(const char *szMaterialTexture, const char *szDefaultTexture=nullptr, bool fAddIfNotExist=true, const char *szErrorIfFailed=nullptr)
Definition: C4Texture.cpp:450
bool MatValid(int32_t mat)
Definition: C4Material.h:212
bool LogF(const char *strMessage,...)
Definition: C4Log.cpp:253
bool fEntriesAdded
Definition: C4Texture.h:83
void Copy()
Definition: StdBuf.h:475
bool HasTextures(C4Group &hGroup)
Definition: C4Texture.cpp:407
void Clear()
Definition: C4Texture.cpp:54
void SReplaceChar(char *str, char fc, char tc)
Definition: Standard.cpp:318
int32_t PixCol2Tex(BYTE pixc)
Definition: C4Landscape.h:214
C4TexMapEntry()
Definition: C4Texture.cpp:49