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

#include <C4MapCreatorS2.h>

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

Public Member Functions

 C4MCPoint (C4MCNode *pOwner=nullptr)
 
 C4MCPoint (C4MCParser *pParser, C4MCNode *pOwner, C4MCPoint &rTemplate, bool fClone)
 
C4MCNodeclone (C4MCParser *pParser, C4MCNode *pToNode) override
 
void Evaluate () override
 
bool SetField (C4MCParser *pParser, const char *szField, const char *szSVal, int32_t iVal, C4MCTokenType ValType) override
 
C4MCNodeType Type () override
 
void Clear ()
 
void Reg2Owner (C4MCNode *pOwner)
 
virtual C4MCOverlayOverlay ()
 
C4MCOverlayOwnerOverlay ()
 

Public Attributes

int32_t X
 
int32_t Y
 
int_bool RX
 
int_bool RY
 
C4MCNodeOwner
 
C4MCNodeChild0
 
C4MCNodeChildL
 
C4MCNodePrev
 
C4MCNodeNext
 
C4MapCreatorS2MapCreator
 
char Name [C4MaxName]
 

Protected Member Functions

void Default ()
 
virtual bool GlobalScope ()
 
virtual bool SetOp (C4MCTokenType eOp)
 
C4MCNodeGetNodeByName (const char *szName)
 
int32_t IntPar (C4MCParser *pParser, const char *szSVal, int32_t iVal, C4MCTokenType ValType)
 
const char * StrPar (C4MCParser *pParser, const char *szSVal, int32_t iVal, C4MCTokenType ValType)
 
void ReEvaluate ()
 

Friends

class C4MapCreatorS2
 
class C4MCParser
 

Detailed Description

Definition at line 248 of file C4MapCreatorS2.h.

Constructor & Destructor Documentation

C4MCPoint::C4MCPoint ( C4MCNode pOwner = nullptr)

Definition at line 642 of file C4MapCreatorS2.cpp.

References X, and Y.

Referenced by clone().

642  : C4MCNode(pOwner)
643 {
644  // zero members
645  X=Y=0;
646 }
C4MCNode(C4MCNode *pOwner=nullptr)

Here is the caller graph for this function:

C4MCPoint::C4MCPoint ( C4MCParser pParser,
C4MCNode pOwner,
C4MCPoint rTemplate,
bool  fClone 
)

Definition at line 648 of file C4MapCreatorS2.cpp.

References RX, RY, X, and Y.

648  : C4MCNode(pParser, pOwner, rTemplate, fClone)
649 {
650  // copy fields
651  X=rTemplate.X; Y=rTemplate.Y;
652  RX=rTemplate.RX; RY=rTemplate.RY;
653 }
C4MCNode(C4MCNode *pOwner=nullptr)
int_bool RY
int_bool RX

Member Function Documentation

void C4MCNode::Clear ( )
inherited

Definition at line 240 of file C4MapCreatorS2.cpp.

References C4MCNode::Child0.

Referenced by C4MapCreatorS2::Clear(), and C4MCNode::~C4MCNode().

241 {
242  // delete all children; they'll unreg themselves
243  while (Child0) delete Child0;
244 }
C4MCNode * Child0

Here is the caller graph for this function:

C4MCNode* C4MCPoint::clone ( C4MCParser pParser,
C4MCNode pToNode 
)
inlineoverridevirtual

Reimplemented from C4MCNode.

Definition at line 254 of file C4MapCreatorS2.h.

References C4MCPoint().

254 { return new C4MCPoint(pParser, pToNode, *this, true); }
C4MCPoint(C4MCNode *pOwner=nullptr)

Here is the call graph for this function:

void C4MCPoint::Default ( )
protected

Definition at line 655 of file C4MapCreatorS2.cpp.

References X, and Y.

Referenced by C4MapCreatorS2::Default().

656 {
657  X=Y=0;
658 }

Here is the caller graph for this function:

void C4MCPoint::Evaluate ( )
overridevirtual

Reimplemented from C4MCNode.

Definition at line 677 of file C4MapCreatorS2.cpp.

References C4MCNode::Evaluate(), C4MCNode::int_bool::Evaluate(), C4MCOverlay::Hgt, C4MCNode::Owner, C4MCNode::OwnerOverlay(), RX, RY, C4MCOverlay::Wdt, C4MCOverlay::X, X, C4MCOverlay::Y, and Y.

678 {
679  // inherited
681  // get mat color
682  // calc size
683  if (Owner)
684  {
685  C4MCOverlay *pOwnrOvrl;
686  if ((pOwnrOvrl=OwnerOverlay()))
687  {
688  X = RX.Evaluate(pOwnrOvrl->Wdt) + pOwnrOvrl->X;
689  Y = RY.Evaluate(pOwnrOvrl->Hgt) + pOwnrOvrl->Y;
690  }
691  }
692 }
C4MCOverlay * OwnerOverlay()
virtual void Evaluate()
C4MCNode * Owner
int_bool RY
int32_t Evaluate(int32_t relative_to)
int_bool RX

Here is the call graph for this function:

C4MCNode * C4MCNode::GetNodeByName ( const char *  szName)
protectedinherited

Definition at line 255 of file C4MapCreatorS2.cpp.

References C4MCNode::ChildL, C4MCNode::GetNodeByName(), C4MCNode::Owner, C4MCNode::Prev, and SEqual().

Referenced by C4MapCreatorS2::GetMap(), and C4MCNode::GetNodeByName().

256 {
257  // search local list (backwards: last node has highest priority)
258  for (C4MCNode *pChild=ChildL; pChild; pChild=pChild->Prev)
259  // name match?
260  if (SEqual(pChild->Name, szName))
261  // yeah, success!
262  return pChild;
263  // search owner, if present
264  if (Owner) return Owner->GetNodeByName(szName);
265  // nothing found
266  return nullptr;
267 }
C4MCNode * GetNodeByName(const char *szName)
bool SEqual(const char *szStr1, const char *szStr2)
Definition: Standard.h:93
C4MCNode * ChildL
C4MCNode * Owner
C4MCNode * Prev

Here is the call graph for this function:

Here is the caller graph for this function:

virtual bool C4MCNode::GlobalScope ( )
inlineprotectedvirtualinherited

Reimplemented in C4MapCreatorS2.

Definition at line 162 of file C4MapCreatorS2.h.

162 { return false; } // whether node is a global scope
int32_t C4MCNode::IntPar ( C4MCParser pParser,
const char *  szSVal,
int32_t  iVal,
C4MCTokenType  ValType 
)
protectedinherited

Definition at line 275 of file C4MapCreatorS2.cpp.

References C4MCErr_FieldValInvalid, MCT_INT, MCT_PERCENT, and MCT_PX.

Referenced by C4MCOverlay::SetField(), and SetField().

276 {
277  // check if int32_t
278  if (ValType == MCT_INT || ValType == MCT_PERCENT || ValType == MCT_PX)
279  return iVal;
280  throw C4MCParserErr(pParser, C4MCErr_FieldValInvalid, szSVal);
281 }
#define C4MCErr_FieldValInvalid

Here is the caller graph for this function:

virtual C4MCOverlay* C4MCNode::Overlay ( )
inlinevirtualinherited

Reimplemented in C4MCOverlay.

Definition at line 187 of file C4MapCreatorS2.h.

Referenced by C4MCOverlay::FirstOfChain(), and C4MCOverlay::PeekPix().

187 { return nullptr; } // return overlay, if this is one

Here is the caller graph for this function:

C4MCOverlay * C4MCNode::OwnerOverlay ( )
inherited

Definition at line 246 of file C4MapCreatorS2.cpp.

References C4MCOverlay::Overlay(), and C4MCNode::Owner.

Referenced by C4MCOverlay::Evaluate(), Evaluate(), and PreparePeek().

247 {
248  for (C4MCNode *pOwnr=Owner; pOwnr; pOwnr=pOwnr->Owner)
249  if (C4MCOverlay *pOwnrOvrl=pOwnr->Overlay())
250  return pOwnrOvrl;
251  // no overlay-owner
252  return nullptr;
253 }
C4MCOverlay * Overlay() override
C4MCNode * Owner

Here is the call graph for this function:

Here is the caller graph for this function:

void C4MCNode::ReEvaluate ( )
protectedinherited

Definition at line 294 of file C4MapCreatorS2.cpp.

References C4MCNode::Child0, C4MCNode::Evaluate(), and C4MCNode::Next.

Referenced by C4MCMap::SetSize().

295 {
296  // evaluate ourselves
297  Evaluate();
298  // evaluate children
299  for (C4MCNode *pChild=Child0; pChild; pChild=pChild->Next)
300  pChild->ReEvaluate();
301 }
virtual void Evaluate()
C4MCNode * Child0
C4MCNode * Next

Here is the call graph for this function:

Here is the caller graph for this function:

void C4MCNode::Reg2Owner ( C4MCNode pOwner)
inherited

Definition at line 216 of file C4MapCreatorS2.cpp.

References C4MCNode::Child0, C4MCNode::ChildL, C4MCNode::MapCreator, C4MCNode::Next, C4MCNode::Owner, and C4MCNode::Prev.

Referenced by C4MCNode::C4MCNode().

217 {
218  // init list
219  Child0=ChildL=nullptr;
220  // owner?
221  if ((Owner=pOwner))
222  {
223  // link into it
224  if ((Prev = Owner->ChildL))
225  Prev->Next = this;
226  else
227  Owner->Child0 = this;
228  Owner->ChildL = this;
229  MapCreator=pOwner->MapCreator;
230  }
231  else
232  {
233  Prev=nullptr;
234  MapCreator=nullptr;
235  }
236  // we're always last entry
237  Next=nullptr;
238 }
C4MCNode * Child0
C4MCNode * ChildL
C4MCNode * Owner
C4MCNode * Next
C4MCNode * Prev
C4MapCreatorS2 * MapCreator

Here is the caller graph for this function:

bool C4MCPoint::SetField ( C4MCParser pParser,
const char *  szField,
const char *  szSVal,
int32_t  iVal,
C4MCTokenType  ValType 
)
overridevirtual

Reimplemented from C4MCNode.

Definition at line 660 of file C4MapCreatorS2.cpp.

References C4MCNode::IntPar(), MCT_INT, MCT_PERCENT, RX, RY, SEqual(), and C4MCNode::int_bool::Set().

661 {
662  // only explicit %/px
663  if (ValType == MCT_INT) return false;
664  if (SEqual (szField, "x"))
665  {
666  RX.Set(IntPar, ValType == MCT_PERCENT);
667  return true;
668  }
669  else if (SEqual (szField, "y"))
670  {
671  RY.Set(IntPar, ValType == MCT_PERCENT);
672  return true;
673  }
674  return false;
675 }
bool SEqual(const char *szStr1, const char *szStr2)
Definition: Standard.h:93
int_bool RY
int32_t IntPar(C4MCParser *pParser, const char *szSVal, int32_t iVal, C4MCTokenType ValType)
void Set(int32_t value, bool percent)
int_bool RX

Here is the call graph for this function:

virtual bool C4MCNode::SetOp ( C4MCTokenType  eOp)
inlineprotectedvirtualinherited

Reimplemented in C4MCOverlay.

Definition at line 163 of file C4MapCreatorS2.h.

163 { return false; } // set following operator
const char * C4MCNode::StrPar ( C4MCParser pParser,
const char *  szSVal,
int32_t  iVal,
C4MCTokenType  ValType 
)
protectedinherited

Definition at line 283 of file C4MapCreatorS2.cpp.

References C4MCErr_FieldValInvalid, and MCT_IDTF.

Referenced by C4MCOverlay::SetField().

284 {
285  // check if identifier
286  if (ValType != MCT_IDTF)
287  throw C4MCParserErr(pParser, C4MCErr_FieldValInvalid, szSVal);
288  return szSVal;
289 }
#define C4MCErr_FieldValInvalid

Here is the caller graph for this function:

C4MCNodeType C4MCPoint::Type ( )
inlineoverridevirtual

Reimplemented from C4MCNode.

Definition at line 267 of file C4MapCreatorS2.h.

References MCN_Point.

267 { return MCN_Point; } // get node type

Friends And Related Function Documentation

friend class C4MapCreatorS2
friend

Definition at line 269 of file C4MapCreatorS2.h.

friend class C4MCParser
friend

Definition at line 270 of file C4MapCreatorS2.h.

Member Data Documentation

C4MCNode * C4MCNode::ChildL
inherited
char C4MCNode::Name[C4MaxName]
inherited

Definition at line 149 of file C4MapCreatorS2.h.

Referenced by AlgoScript(), and C4MCNode::C4MCNode().

int_bool C4MCPoint::RX

Definition at line 261 of file C4MapCreatorS2.h.

Referenced by C4MCPoint(), Evaluate(), and SetField().

int_bool C4MCPoint::RY

Definition at line 261 of file C4MapCreatorS2.h.

Referenced by C4MCPoint(), Evaluate(), and SetField().

int32_t C4MCPoint::X

Definition at line 260 of file C4MapCreatorS2.h.

Referenced by C4MCPoint(), Default(), and Evaluate().

int32_t C4MCPoint::Y

Definition at line 260 of file C4MapCreatorS2.h.

Referenced by C4MCPoint(), Default(), and Evaluate().


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