OpenClonk
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() [1/2]

C4MCPoint::C4MCPoint ( C4MCNode pOwner = nullptr)

Definition at line 642 of file C4MapCreatorS2.cpp.

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

References X, and Y.

Referenced by clone().

Here is the caller graph for this function:

◆ C4MCPoint() [2/2]

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

Definition at line 648 of file C4MapCreatorS2.cpp.

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 }
int_bool RY
int_bool RX

References RX, RY, X, and Y.

Member Function Documentation

◆ Clear()

void C4MCNode::Clear ( )
inherited

Definition at line 240 of file C4MapCreatorS2.cpp.

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

References C4MCNode::Child0.

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

Here is the caller graph for this function:

◆ clone()

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

Reimplemented from C4MCNode.

Definition at line 254 of file C4MapCreatorS2.h.

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

References C4MCPoint().

Here is the call graph for this function:

◆ Default()

void C4MCPoint::Default ( )
protected

Definition at line 655 of file C4MapCreatorS2.cpp.

656 {
657  X=Y=0;
658 }

References X, and Y.

Referenced by C4MapCreatorS2::Default().

Here is the caller graph for this function:

◆ Evaluate()

void C4MCPoint::Evaluate ( )
overridevirtual

Reimplemented from C4MCNode.

Definition at line 677 of file C4MapCreatorS2.cpp.

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 }
int32_t Evaluate(int32_t relative_to)
C4MCOverlay * OwnerOverlay()
C4MCNode * Owner
virtual void Evaluate()

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

Here is the call graph for this function:

◆ GetNodeByName()

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

Definition at line 255 of file C4MapCreatorS2.cpp.

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 }
bool SEqual(const char *szStr1, const char *szStr2)
Definition: Standard.h:93
C4MCNode * ChildL
C4MCNode * GetNodeByName(const char *szName)
C4MCNode * Prev

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

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

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GlobalScope()

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

◆ IntPar()

int32_t C4MCNode::IntPar ( C4MCParser pParser,
const char *  szSVal,
int32_t  iVal,
C4MCTokenType  ValType 
)
protectedinherited

Definition at line 275 of file C4MapCreatorS2.cpp.

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
@ MCT_INT
@ MCT_PX
@ MCT_PERCENT

References C4MCErr_FieldValInvalid, MCT_INT, MCT_PERCENT, and MCT_PX.

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

Here is the caller graph for this function:

◆ Overlay()

virtual C4MCOverlay* C4MCNode::Overlay ( )
inlinevirtualinherited

Reimplemented in C4MCOverlay.

Definition at line 187 of file C4MapCreatorS2.h.

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

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

Here is the caller graph for this function:

◆ OwnerOverlay()

C4MCOverlay * C4MCNode::OwnerOverlay ( )
inherited

Definition at line 246 of file C4MapCreatorS2.cpp.

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

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

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

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ReEvaluate()

void C4MCNode::ReEvaluate ( )
protectedinherited

Definition at line 294 of file C4MapCreatorS2.cpp.

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

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

Referenced by C4MCMap::SetSize().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Reg2Owner()

void C4MCNode::Reg2Owner ( C4MCNode pOwner)
inherited

Definition at line 216 of file C4MapCreatorS2.cpp.

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 }
C4MapCreatorS2 * MapCreator

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

Referenced by C4MCNode::C4MCNode().

Here is the caller graph for this function:

◆ SetField()

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.

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 }
void Set(int32_t value, bool percent)
int32_t IntPar(C4MCParser *pParser, const char *szSVal, int32_t iVal, C4MCTokenType ValType)

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

Here is the call graph for this function:

◆ SetOp()

virtual bool C4MCNode::SetOp ( C4MCTokenType  eOp)
inlineprotectedvirtualinherited

Reimplemented in C4MCOverlay.

Definition at line 163 of file C4MapCreatorS2.h.

163 { return false; } // set following operator

◆ StrPar()

const char * C4MCNode::StrPar ( C4MCParser pParser,
const char *  szSVal,
int32_t  iVal,
C4MCTokenType  ValType 
)
protectedinherited

Definition at line 283 of file C4MapCreatorS2.cpp.

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

References C4MCErr_FieldValInvalid, and MCT_IDTF.

Referenced by C4MCOverlay::SetField().

Here is the caller graph for this function:

◆ Type()

C4MCNodeType C4MCPoint::Type ( )
inlineoverridevirtual

Reimplemented from C4MCNode.

Definition at line 267 of file C4MapCreatorS2.h.

267 { return MCN_Point; } // get node type
@ MCN_Point

References MCN_Point.

Friends And Related Function Documentation

◆ C4MapCreatorS2

friend class C4MapCreatorS2
friend

Definition at line 269 of file C4MapCreatorS2.h.

◆ C4MCParser

friend class C4MCParser
friend

Definition at line 270 of file C4MapCreatorS2.h.

Member Data Documentation

◆ Child0

◆ ChildL

C4MCNode * C4MCNode::ChildL
inherited

◆ MapCreator

◆ Name

char C4MCNode::Name[C4MaxName]
inherited

Definition at line 149 of file C4MapCreatorS2.h.

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

◆ Next

◆ Owner

◆ Prev

◆ RX

int_bool C4MCPoint::RX

Definition at line 261 of file C4MapCreatorS2.h.

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

◆ RY

int_bool C4MCPoint::RY

Definition at line 261 of file C4MapCreatorS2.h.

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

◆ X

int32_t C4MCPoint::X

Definition at line 260 of file C4MapCreatorS2.h.

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

◆ Y

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: