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 56 of file C4Particles.cpp.

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

57 {
58  // zero fields
59  Gfx.Default();
60  // link into list
61  if (!Particles.definitions.first)
62  {
63  previous = nullptr;
64  Particles.definitions.first = this;
65  }
66  else
67  {
69  previous->next = this;
70  }
71  Particles.definitions.last = this;
72  next = 0;
73 }
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 75 of file C4Particles.cpp.

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

76 {
77  // clear
78  Clear();
79  // unlink from list
80  if (previous) previous->next = next; else Particles.definitions.first = next;
82 }
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 84 of file C4Particles.cpp.

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

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

85 {
86  Name.Clear();
87 }
void Clear()
Definition: StdBuf.h:466
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 50 of file C4Particles.cpp.

References mkNamingAdapt().

Referenced by Load().

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

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 39 of file C4Particles.cpp.

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

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

Here is the call graph for this function:

bool C4ParticleDef::Load ( C4Group group)

Definition at line 89 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().

90 {
91  // store file
92  Filename.Copy(group.GetFullName());
93  // load
94  char *particle_source;
95  if (group.LoadEntry(C4CFN_ParticleCore,&particle_source,nullptr,1))
96  {
97  if (!Compile(particle_source, Filename.getData()))
98  {
99  DebugLogF("invalid particle def at '%s'", group.GetFullName().getData());
100  delete [] particle_source; return false;
101  }
102  delete [] particle_source;
103  // load graphics
105  {
106  DebugLogF("particle %s has no valid graphics defined", Name.getData());
107  return false;
108  }
109  // set facet, if assigned - otherwise, assume full surface
111  // set phase num
112  int32_t Q; Gfx.GetPhaseNum(PhasesX, Q);
113  Length = PhasesX * Q;
114  if (!Length)
115  {
116  DebugLogF("invalid facet for particle '%s'", Name.getData());
117  return false;
118  }
119  // calc aspect
120  Aspect=(float) Gfx.Hgt/Gfx.Wdt;
121 
122  // particle overloading
123  C4ParticleDef *def_overload;
124  if ((def_overload = Particles.definitions.GetDef(Name.getData(), this)))
125  {
127  { char ostr[250]; sprintf(ostr,LoadResStr("IDS_PRC_DEFOVERLOAD"),def_overload->Name.getData(),"<particle>"); Log(ostr); }
128  delete def_overload;
129  }
130  // success
131  return true;
132  }
133  return false;
134 }
const char * getData() const
Definition: StdBuf.h:442
C4Config Config
Definition: C4Config.cpp:833
int32_t VerboseObjectLoading
Definition: C4Config.h:99
#define sprintf
Definition: Standard.h:164
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:253
int32_t Wdt
Definition: C4Rect.h:30
bool DebugLogF(const char *strMessage...)
Definition: C4Log.cpp:278
int32_t y
Definition: C4Rect.h:30
StdStrBuf GetFullName() const
Definition: C4Group.cpp:2078
const int C4SF_MipMap
Definition: C4Surface.h:50
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:50
int32_t x
Definition: C4Rect.h:30
float Hgt
Definition: C4Facet.h:118
#define C4CFN_ParticleCore
Definition: C4Components.h:48
bool Log(const char *szMessage)
Definition: C4Log.cpp:192
StdStrBuf Name
Definition: C4Particles.h:73
int32_t Hgt
Definition: C4Rect.h:30
C4Surface * Surface
Definition: C4Facet.h:117
C4ParticleDef * GetDef(const char *name, C4ParticleDef *exclude=nullptr)
const int C4FCT_Full
Definition: C4FacetEx.h:26
void Copy()
Definition: StdBuf.h:467
float Wdt
Definition: C4Facet.h:118

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4ParticleDef::Reload ( )

Definition at line 136 of file C4Particles.cpp.

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

Referenced by C4Game::ReloadParticle().

137 {
138  // no file?
139  if (!Filename[0]) return false;
140  // open group
141  C4Group group;
142  if (!group.Open(Filename.getData())) return false;
143  // reset class
144  Clear();
145  // load
146  return Load(group);
147 }
const char * getData() const
Definition: StdBuf.h:442
bool Load(C4Group &group)
Definition: C4Particles.cpp:89
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: