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

#include <C4Particles.h>

Inheritance diagram for C4ParticleDef:
[legend]
Collaboration diagram for C4ParticleDef:
[legend]

Public Member Functions

 C4ParticleDef ()
 
 ~C4ParticleDef ()
 
void Clear ()
 
bool Load (C4Group &group)
 
bool Reload ()
 
void CompileFunc (StdCompiler *compiler)
 
bool Compile (char *particle_source, const char *name)
 

Public Attributes

C4ParticleDefprevious
 
C4ParticleDefnext
 
StdStrBuf Filename
 
C4FacetSurface Gfx
 
int32_t Length
 
int32_t PhasesX
 
float Aspect
 
StdStrBuf Name
 
C4Rect GfxFace
 

Detailed Description

Definition at line 83 of file C4Particles.h.

Constructor & Destructor Documentation

C4ParticleDef::C4ParticleDef ( )

Definition at line 58 of file C4Particles.cpp.

References C4FacetSurface::Default(), C4ParticleSystem::definitions, Gfx, next, Particles, and previous.

59 {
60  // zero fields
61  Gfx.Default();
62  // link into list
63  if (!Particles.definitions.first)
64  {
65  previous = nullptr;
66  Particles.definitions.first = this;
67  }
68  else
69  {
71  previous->next = this;
72  }
73  Particles.definitions.last = this;
74  next = 0;
75 }
C4ParticleSystem Particles
C4FacetSurface Gfx
Definition: C4Particles.h:90
void Default()
Definition: C4FacetEx.h:43
C4ParticleSystemDefinitionList definitions
Definition: C4Particles.h:510
C4ParticleDef * previous
Definition: C4Particles.h:86
C4ParticleDef * next
Definition: C4Particles.h:86

Here is the call graph for this function:

C4ParticleDef::~C4ParticleDef ( )

Definition at line 77 of file C4Particles.cpp.

References Clear(), C4ParticleSystem::definitions, next, Particles, and previous.

78 {
79  // clear
80  Clear();
81  // unlink from list
82  if (previous) previous->next = next; else Particles.definitions.first = next;
84 }
C4ParticleSystem Particles
C4ParticleSystemDefinitionList definitions
Definition: C4Particles.h:510
C4ParticleDef * previous
Definition: C4Particles.h:86
C4ParticleDef * next
Definition: C4Particles.h:86

Here is the call graph for this function:

Member Function Documentation

void C4ParticleDef::Clear ( )

Definition at line 86 of file C4Particles.cpp.

References StdStrBuf::Clear(), and C4ParticleDefCore::Name.

Referenced by Reload(), and ~C4ParticleDef().

87 {
88  Name.Clear();
89 }
void Clear()
Definition: StdBuf.h:474
StdStrBuf Name
Definition: C4Particles.h:73

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4ParticleDefCore::Compile ( char *  particle_source,
const char *  name 
)
inherited

Definition at line 52 of file C4Particles.cpp.

References mkNamingAdapt().

Referenced by Load().

53 {
54  return CompileFromBuf_LogWarn<StdCompilerINIRead>(mkNamingAdapt(*this, "Particle"),
55  StdStrBuf(particle_source), name);
56 }
StdNamingAdapt< T > mkNamingAdapt(T &&rValue, const char *szName)
Definition: StdAdaptors.h:93

Here is the call graph for this function:

Here is the caller graph for this function:

void C4ParticleDefCore::CompileFunc ( StdCompiler compiler)
inherited

Definition at line 41 of file C4Particles.cpp.

References C4ParticleDefCore::GfxFace, mkNamingAdapt(), C4ParticleDefCore::Name, toC4CStrBuf, and StdCompiler::Value().

42 {
43  pComp->Value(mkNamingAdapt(toC4CStrBuf(Name), "Name", ""));
44  pComp->Value(mkNamingAdapt(GfxFace, "Face"));
45 }
StdNamingAdapt< T > mkNamingAdapt(T &&rValue, const char *szName)
Definition: StdAdaptors.h:93
StdStrBuf Name
Definition: C4Particles.h:73
#define toC4CStrBuf(rBuf)
Definition: StdAdaptors.h:26

Here is the call graph for this function:

bool C4ParticleDef::Load ( C4Group group)

Definition at line 91 of file C4Particles.cpp.

References Aspect, C4CFN_DefGraphics, C4CFN_ParticleCore, C4FCT_Full, C4SF_MipMap, C4ParticleDefCore::Compile(), Config, StdStrBuf::Copy(), DebugLogF(), C4ParticleSystem::definitions, Filename, StdStrBuf::getData(), C4ParticleSystemDefinitionList::GetDef(), C4Group::GetFullName(), C4Facet::GetPhaseNum(), Gfx, C4ParticleDefCore::GfxFace, C4Config::Graphics, C4Rect::Hgt, C4Facet::Hgt, Length, C4FacetSurface::Load(), C4Group::LoadEntry(), LoadResStr(), Log(), C4ParticleDefCore::Name, Particles, PhasesX, C4FacetSurface::Set(), sprintf, C4Facet::Surface, C4ConfigGraphics::VerboseObjectLoading, C4Rect::Wdt, C4Facet::Wdt, C4Rect::x, and C4Rect::y.

Referenced by Reload().

92 {
93  // store file
94  Filename.Copy(group.GetFullName());
95  // load
96  char *particle_source;
97  if (group.LoadEntry(C4CFN_ParticleCore,&particle_source,nullptr,1))
98  {
99  if (!Compile(particle_source, Filename.getData()))
100  {
101  DebugLogF("invalid particle def at '%s'", group.GetFullName().getData());
102  delete [] particle_source; return false;
103  }
104  delete [] particle_source;
105  // load graphics
107  {
108  DebugLogF("particle %s has no valid graphics defined", Name.getData());
109  return false;
110  }
111  // set facet, if assigned - otherwise, assume full surface
113  // set phase num
114  int32_t Q; Gfx.GetPhaseNum(PhasesX, Q);
115  Length = PhasesX * Q;
116  if (!Length)
117  {
118  DebugLogF("invalid facet for particle '%s'", Name.getData());
119  return false;
120  }
121  // calc aspect
122  Aspect=(float) Gfx.Hgt/Gfx.Wdt;
123 
124  // particle overloading
125  C4ParticleDef *def_overload;
126  if ((def_overload = Particles.definitions.GetDef(Name.getData(), this)))
127  {
129  { char ostr[250]; sprintf(ostr,LoadResStr("IDS_PRC_DEFOVERLOAD"),def_overload->Name.getData(),"<particle>"); Log(ostr); }
130  delete def_overload;
131  }
132  // success
133  return true;
134  }
135  return false;
136 }
const char * getData() const
Definition: StdBuf.h:450
C4Config Config
Definition: C4Config.cpp:837
int32_t VerboseObjectLoading
Definition: C4Config.h:100
#define sprintf
Definition: Standard.h:171
C4ParticleSystem Particles
bool Load(C4Group &hGroup, const char *szName, int iWdt, int iHgt, bool fNoErrIfNotFound, int iFlags)
Definition: C4FacetEx.cpp:78
bool GetPhaseNum(int32_t &rX, int32_t &rY)
Definition: C4Facet.cpp:472
int32_t PhasesX
Definition: C4Particles.h:92
int32_t Length
Definition: C4Particles.h:91
bool LoadEntry(const char *szEntryName, char **lpbpBuf, size_t *ipSize=nullptr, int iAppendZeros=0)
Definition: C4Group.cpp:1893
C4FacetSurface Gfx
Definition: C4Particles.h:90
void Set(const C4Facet &cpy)
Definition: C4FacetEx.h:46
const char * LoadResStr(const char *id)
Definition: C4Language.h:83
C4ConfigGraphics Graphics
Definition: C4Config.h:254
int32_t Wdt
Definition: C4Rect.h:32
bool DebugLogF(const char *strMessage...)
Definition: C4Log.cpp:281
int32_t y
Definition: C4Rect.h:32
StdStrBuf GetFullName() const
Definition: C4Group.cpp:2078
const int C4SF_MipMap
Definition: C4Surface.h:52
StdStrBuf Filename
Definition: C4Particles.h:88
C4ParticleSystemDefinitionList definitions
Definition: C4Particles.h:510
#define C4CFN_DefGraphics
Definition: C4Components.h:99
bool Compile(char *particle_source, const char *name)
Definition: C4Particles.cpp:52
int32_t x
Definition: C4Rect.h:32
float Hgt
Definition: C4Facet.h:120
#define C4CFN_ParticleCore
Definition: C4Components.h:48
bool Log(const char *szMessage)
Definition: C4Log.cpp:195
StdStrBuf Name
Definition: C4Particles.h:73
int32_t Hgt
Definition: C4Rect.h:32
C4Surface * Surface
Definition: C4Facet.h:119
const int C4FCT_Full
Definition: C4FacetEx.h:26
void Copy()
Definition: StdBuf.h:475
float Wdt
Definition: C4Facet.h:120
C4ParticleDef * GetDef(const char *name, C4ParticleDef *exclude=0)

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4ParticleDef::Reload ( )

Definition at line 138 of file C4Particles.cpp.

References Clear(), Filename, StdStrBuf::getData(), Load(), and C4Group::Open().

Referenced by C4Game::ReloadParticle().

139 {
140  // no file?
141  if (!Filename[0]) return false;
142  // open group
143  C4Group group;
144  if (!group.Open(Filename.getData())) return false;
145  // reset class
146  Clear();
147  // load
148  return Load(group);
149 }
const char * getData() const
Definition: StdBuf.h:450
bool Load(C4Group &group)
Definition: C4Particles.cpp:91
bool Open(const char *szGroupName, bool fCreate=false)
Definition: C4Group.cpp:514
StdStrBuf Filename
Definition: C4Particles.h:88

Here is the call graph for this function:

Here is the caller graph for this function:

Member Data Documentation

float C4ParticleDef::Aspect

Definition at line 93 of file C4Particles.h.

Referenced by C4ParticleSystem::Create(), and Load().

StdStrBuf C4ParticleDef::Filename

Definition at line 88 of file C4Particles.h.

Referenced by Load(), Reload(), and C4Game::ReloadParticle().

C4FacetSurface C4ParticleDef::Gfx

Definition at line 90 of file C4Particles.h.

Referenced by C4ParticleDef(), and Load().

C4Rect C4ParticleDefCore::GfxFace
inherited
int32_t C4ParticleDef::Length

Definition at line 91 of file C4Particles.h.

Referenced by Load(), and C4Particle::DrawingData::SetPhase().

StdStrBuf C4ParticleDefCore::Name
inherited
C4ParticleDef * C4ParticleDef::next
int32_t C4ParticleDef::PhasesX

Definition at line 92 of file C4Particles.h.

Referenced by Load(), and C4Particle::DrawingData::SetPhase().

C4ParticleDef* C4ParticleDef::previous

Definition at line 86 of file C4Particles.h.

Referenced by C4ParticleDef(), and ~C4ParticleDef().


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